int LicenseSystem::ParseResponse(const String& response, LicenseParse& parse) { ATOMIC_LOGINFOF("%s", response.CString()); if (response.StartsWith("AC_ACTIVATIONSEXCEEDED")) { return 1; } if (response.StartsWith("AC_IDNOTACTIVATED")) { return 4; } if (response.StartsWith("AC_FAILED")) { return 2; } if (!response.StartsWith("WINDOWS")) { ATOMIC_LOGERRORF("Error Parsing Server Response %s", response.CString()); return 3; } String codes = response; codes.Replace("\n", ""); codes.Replace("\r", ""); Vector<String> cvector = codes.Split(' '); for (unsigned i = 0; i < cvector.Size(); i++) { Vector<String> feature = cvector[i].Split('='); if (feature.Size() != 2) continue; if (feature[0] == "WINDOWS") parse.licenseWindows_ = !feature[1].StartsWith("0"); else if (feature[0] == "MAC") parse.licenseMac_ = !feature[1].StartsWith("0"); else if (feature[0] == "ANDROID") parse.licenseAndroid_ = !feature[1].StartsWith("0"); else if (feature[0] == "IOS") parse.licenseIOS_ = !feature[1].StartsWith("0"); else if (feature[0] == "HTML5") parse.licenseHTML5_ = !feature[1].StartsWith("0"); else if (feature[0] == "THREED") parse.licenseModule3D_ = !feature[1].StartsWith("0"); } return 0; }
void FileFilter::AddExtension( const String& ext ) { String x = ext.Trimmed(); if ( !x.StartsWith( '.' ) ) if ( !x.StartsWith( '*' ) ) x = '*' + x; x.ToLowercase(); // case-insensitive file extensions if ( !extensions.Contains( x ) ) extensions.Add( x ); }
String BBWin8Game::PathToFilePath( String path ){ if( !path.StartsWith( "monkey:" ) ){ return path; }else if( path.StartsWith( "monkey://data/" ) ){ auto folder=Windows::ApplicationModel::Package::Current->InstalledLocation; return String( folder->Path )+"/Assets/monkey/"+path.Slice( 14 ); }else if( path.StartsWith( "monkey://internal/" ) ){ auto folder=Windows::Storage::ApplicationData::Current->LocalFolder; return String( folder->Path )+"/"+path.Slice( 18 ); } return ""; }
void DatabaseDemo::HandleInput(const String& input) { // Echo input string to stdout Print(input); row_ = 0; if (input == "quit" || input == "exit") engine_->Exit(); else if (input.StartsWith("set") || input.StartsWith("get")) { // We expect a key/value pair for 'set' command Vector<String> tokens = input.Substring(3).Split(' '); String setting = tokens.Size() ? tokens[0] : ""; if (input.StartsWith("set") && tokens.Size() > 1) { if (setting == "maxrows") maxRows_ = Max(ToUInt(tokens[1]), 1U); else if (setting == "connstr") { String newConnectionString(input.Substring(input.Find(" ", input.Find("connstr")) + 1)); Database* database = GetSubsystem<Database>(); DbConnection* newConnection = database->Connect(newConnectionString); if (newConnection) { database->Disconnect(connection_); connection_ = newConnection; } } } if (tokens.Size()) { if (setting == "maxrows") Print(ToString("maximum rows is set to %d", maxRows_)); else if (setting == "connstr") Print(ToString("connection string is set to %s", connection_->GetConnectionString().CString())); else Print(ToString("Unrecognized setting: %s", setting.CString())); } else Print("Missing setting paramater. Recognized settings are: maxrows, connstr"); } else { // In this sample demo we use the dbCursor event to loop through each row as it is being fetched // Regardless of this event is being used or not, all the fetched rows will be made available in the DbResult object, // unless the dbCursor event handler has instructed to filter out the fetched row from the final result DbResult result = connection_->Execute(input, true); // Number of affected rows is only meaningful for DML statements like insert/update/delete if (result.GetNumAffectedRows() != -1) Print(ToString("Number of affected rows: %d", result.GetNumAffectedRows())); } Print(" "); }
bool UIButton::OnEvent(const tb::TBWidgetEvent &ev) { if (ev.type == EVENT_TYPE_CLICK) { String text = GetText(); if (text.StartsWith("http://") || text.StartsWith("https://")) { FileSystem* fileSystem = GetSubsystem<FileSystem>(); fileSystem->SystemOpen(text); } } return UIWidget::OnEvent(ev); }
void HelpWindow::GoTo(const String& link) { if(IsNull(link) || current_link == link) return; Pos p = GetPos(); if(GoTo0(link)) { if(!IsNull(p.link)) back.Add(p); forward.Clear(); SetBar(); return; } if(link.StartsWith("www.") || link.StartsWith("http") || link.StartsWith("mailto:")) LaunchWebBrowser(link); }
bool LicenseSystem::ValidateKey(const String& key) { if (!key.StartsWith("ATOMIC-")) return false; Vector<String> elements = key.Split('-'); if (elements.Size() != 5) return false; for (unsigned i = 1; i < elements.Size(); i++) { String element = elements[i]; if (element.Length() != 4) return false; for (unsigned j = 0; j < 4; j++) { char c = element[j]; if ((c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) continue; return false; } } return true; }
void PlatformAndroid::HandleRefreshAndroidTargetsEvent(StringHash eventType, VariantMap& eventData) { if (eventType == E_SUBPROCESSOUTPUT) { targetOutput_ += eventData[SubprocessOutput::P_TEXT].GetString(); } else if (eventType == E_SUBPROCESSCOMPLETE) { refreshAndroidTargetsProcess_ = 0; androidTargets_.Clear(); MemoryBuffer reader(targetOutput_.CString(), targetOutput_.Length() + 1); while (!reader.IsEof()) { String line = reader.ReadLine(); if (line.StartsWith("id:")) { //id: 33 or "Google Inc.:Google APIs (x86 System Image):19" Vector<String> elements = line.Split('\"'); if (elements.Size() == 2) { String api = elements[1]; androidTargets_.Push(api); } } } SendEvent(E_ANDROIDTARGETSREFRESHED); } }
void FromString<String>::Function(String& out, String& value, const String& string) { if (string.StartsWith('"')) { for (std::size_t i = 1; i < string.Length(); ++i) { if (string[i] == '"') { out = string.SubString(i + 1); return; } else { value += string[i]; } } // We've reached the end of the String out = ""; } else { value = ""; out = string; } }
String FileUtilities::Combine(const String &path1, const String &path2) { String firstHalf = path1; String secondHalf = path2; if (firstHalf.EndsWith(_T("\\")) || firstHalf.EndsWith(_T("/"))) firstHalf = firstHalf.Mid(0, firstHalf.GetLength() -1); if (secondHalf.StartsWith(_T("\\")) || secondHalf.StartsWith(_T("/"))) secondHalf = secondHalf.Mid(1); String result = firstHalf + "\\" + secondHalf; return result; }
void ChoiceForm::UpdateChoiceOptions(GraphicsUI::ComboBox * cmb) { for (auto & choiceCtrl : comboBoxChoiceNames) { String option = choiceCtrl.Key->GetTextItem(GetSelIdx(choiceCtrl.Key))->GetText(); if (option.StartsWith(L"(auto)")) { existingChoices.Remove(choiceCtrl.Value); } } String choiceName; if (comboBoxChoiceNames.TryGetValue(cmb, choiceName)) { existingChoices.Remove(choiceName); auto selText = cmb->GetTextItem(GetSelIdx(cmb))->GetText(); if (!selText.StartsWith(L"(auto)")) existingChoices[choiceName] = Spire::Compiler::ShaderChoiceValue::Parse(selText); } auto choices = choiceControl->GetChoices(currentShaderName, existingChoices); for (auto & choice : choices) { GraphicsUI::ComboBox * cmbCtrl = nullptr; if (choiceComboBoxes.TryGetValue(choice.ChoiceName, cmbCtrl)) { Spire::Compiler::ShaderChoiceValue currentSelection; existingChoices.TryGetValue(choice.ChoiceName, currentSelection); if (!choice.Options.Contains(currentSelection)) { existingChoices.Remove(choice.ChoiceName); cmbCtrl->SetSelectedIndex(0); } } } }
FileFormat::FileFormat( const String& nameExtOrMime, bool toRead, bool toWrite ) : FileFormatBase() { if ( nameExtOrMime.IsEmpty() ) throw Error( "FileFormat: Empty format name, file extension or MIME type specified" ); m_data = new FileFormatPrivate; if ( nameExtOrMime.Contains( '/' ) ) { IsoString mimeType( nameExtOrMime ); m_data->handle = (*API->FileFormat->GetFileFormatByMimeType)( ModuleHandle(), mimeType.c_str(), toRead, toWrite ); if ( m_data->handle == nullptr ) throw Error( "FileFormat: No installed image file format was found " "for the specified MIME type \'" + nameExtOrMime + "\' and access conditions" ); } else if ( nameExtOrMime.StartsWith( '.' ) ) { m_data->handle = (*API->FileFormat->GetFileFormatByFileExtension)( ModuleHandle(), nameExtOrMime.c_str(), toRead, toWrite ); if ( m_data->handle == nullptr ) throw Error( "FileFormat: No installed image file format was found " "for the specified file extension \'" + nameExtOrMime + "\'and access conditions" ); } else { IsoString id( nameExtOrMime ); m_data->handle = (*API->FileFormat->GetFileFormatByName)( ModuleHandle(), id.c_str() ); if ( m_data->handle == nullptr ) throw Error( "FileFormat: No installed image file format was found " "with the specified identifier \'" + nameExtOrMime + '\'' ); } m_data->GetCapabilities(); }
bool FileSystem::DirExists(const String& pathName) const { if (!CheckAccess(pathName)) return false; #ifndef WIN32 // Always return true for the root directory if (pathName == "/") return true; #endif String fixedName = GetNativePath(RemoveTrailingSlash(pathName)); #ifdef ANDROID /// \todo Actually check for existence, now true is always returned for directories within the APK if (fixedName.StartsWith("/apk/")) return true; #endif #ifdef WIN32 DWORD attributes = GetFileAttributesW(WString(fixedName).CString()); if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)) return false; #else struct stat st; if (stat(fixedName.CString(), &st) || !(st.st_mode & S_IFDIR)) return false; #endif return true; }
bool FileSystem::FileExists(const String& fileName) const { if (!CheckAccess(GetPath(fileName))) return false; String fixedName = GetNativePath(RemoveTrailingSlash(fileName)); #ifdef ANDROID if (fixedName.StartsWith("/apk/")) { SDL_RWops* rwOps = SDL_RWFromFile(fileName.Substring(5).CString(), "rb"); if (rwOps) { SDL_RWclose(rwOps); return true; } else return false; } #endif #ifdef WIN32 DWORD attributes = GetFileAttributesW(WString(fixedName).CString()); if (attributes == INVALID_FILE_ATTRIBUTES || attributes & FILE_ATTRIBUTE_DIRECTORY) return false; #else struct stat st; if (stat(fixedName.CString(), &st) || st.st_mode & S_IFDIR) return false; #endif return true; }
void Ide::OpenATopic() { String t = doc.GetCurrent(); if(!t.StartsWith("topic:")) return; OpenTopic(t); }
bool CSComponentAssembly::PreloadClassAssemblies() { // TEMPORARY SOLUTION, Desktop only ATOMIC_LOGINFO("Preloading Class Assemblies"); Context* context = ScriptSystem::GetContext(); assert(context); ResourceCache* cache = context->GetSubsystem<ResourceCache>(); FileSystem* fileSystem = context->GetSubsystem<FileSystem>(); const StringVector& resourceDirs = cache->GetResourceDirs(); for (unsigned i = 0; i < resourceDirs.Size(); i++) { const String& resourceDir = resourceDirs[i]; ATOMIC_LOGINFOF("Scanning: %s", resourceDir.CString()); StringVector results; fileSystem->ScanDir(results, resourceDir, "*.dll", SCAN_FILES, true); for (unsigned j = 0; j < results.Size(); j++) { // FIXME: This filtering is necessary as we're loading setting project root folder as a resource dir // https://github.com/AtomicGameEngine/AtomicGameEngine/issues/1037 String filter = results[j].ToLower(); if (filter.StartsWith("atomicnet/") || filter.StartsWith("resources/")) { ATOMIC_LOGINFOF("Skipping Assembly: %s (https://github.com/AtomicGameEngine/AtomicGameEngine/issues/1037)", results[j].CString()); continue; } ATOMIC_LOGINFOF("Loading Assembly: %s", results[j].CString()); cache->GetResource<CSComponentAssembly>(results[j]); } } return true; }
bool FileUtilities::IsUNCPath(const String &sPath) { if (sPath.StartsWith(_T("\\\\"))) return true; else return false; }
bool IsNestReadOnly(const String& path) { Vector<String> d = GetUppDirs(); for(int i = 0; i < d.GetCount(); i++) if(path.StartsWith(d[i]) && FileExists(AppendFileName(d[i], "readonly"))) return true; return false; }
void CodeBrowser::Load() { String find = ToUpper((String)~search); String match = ToUpper((String)~search_scope); String pm = GetPm(); Vector<String> txt; Vector<Value> ndx; Index<int> fi; Index<String> fs; for(int i = 0; i < CodeBase().GetCount(); i++) { String s = CodeBase().GetKey(i); const Array<CppItem>& n = CodeBase()[i]; if(s.GetCount()) if(MatchCib(s, match) && (MatchCib(s, find) || HasItem(n, find)) && MatchPm(n, pm)) { txt.Add(s); ndx.Add(s); } for(int i = 0; i < n.GetCount(); i++) { int f = n[i].file; if(fi.Find(f) < 0) { String s = GetFileText(GetSourceFilePath(f)); if(s.StartsWith(pm) && MatchCib(s, match) && (IsNull(find) || MatchCib(s, find) || n[i].uname.StartsWith(find))) { txt.Add(s); ndx.Add(f); fs.Add(s); fi.Add(f); } } } } const Workspace& wspc = GetIdeWorkspace(); for(int i = 0; i < wspc.GetCount(); i++) { String pn = wspc[i]; const Package& p = wspc.GetPackage(i); String pp = PackageDirectory(pn); for(int j = 0; j < p.GetCount(); j++) if(!p[j].separator) { String fn = AppendFileName(pp, p[j]); String s = GetFileText(AppendFileName(pn, p[j])); if(fs.Find(s) < 0 && (IsNull(find) || MatchCib(s, find)) && MatchCib(s, match) && MatchPm(fn, pm)) { int f = GetSourceFileIndex(SourcePath(pn, p[j])); txt.Add(s); ndx.Add(f); fs.Add(s); } } } IndexSort(txt, ndx, ScopeLess()); Value key = scope.GetKey(); int sc = scope.GetCursorSc(); scope.Clear(); for(int i = 0; i < txt.GetCount(); i++) scope.Add(IsString(ndx[i]) ? ndx[i] : Null, txt[i], ndx[i]); if(scope.FindSetCursor(key)) scope.ScCursor(sc); // clear.Enable(IsSearch()); }
bool SQLScriptRunner::ExecuteScript(shared_ptr<DALConnection> connectionObject, const String &sFile, String &sErrorMessage) { SQLScriptParser oParser(connectionObject->GetSettings(), sFile); if (!oParser.Parse(sErrorMessage)) { sErrorMessage = "Parsing of SQL script failed: " + sFile + "\r\nError:" + sErrorMessage; return false; } if (oParser.GetNoOfCommands() == 0) { sErrorMessage = "Found no SQL commands in file : " + sFile; return false; } // 30 minute timeout per statement. Should hopefully never be needed. connectionObject->SetTimeout(60 * 30); for (int i = 0; i < oParser.GetNoOfCommands(); i++) { String sCommand = oParser.GetCommand(i); if (sCommand.StartsWith(_T("@@@"))) { // Remove leading @@@. sCommand = sCommand.Mid(3); // Remove trailing @@@ sCommand = sCommand.Mid(0, sCommand.Find(_T("@@@"))); MacroParser parser(sCommand); Macro macro = parser.Parse(); if (macro.GetType() == Macro::Unknown) { sErrorMessage = "Parsing of SQL script failed. Unknown macro. " + sFile + "\r\nMacro:" + sCommand; return false; } shared_ptr<IMacroExpander> macroExpander = connectionObject->CreateMacroExpander(); if (!macroExpander->ProcessMacro(connectionObject, macro, sErrorMessage)) return false; } else { if (connectionObject->TryExecute(SQLCommand(sCommand), sErrorMessage, 0, 0) != DALConnection::DALSuccess) { return false; } } } connectionObject->SetTimeout(30); return true; }
void LicenseSystem::HandleDeactivate(StringHash eventType, VariantMap& eventData) { Editor* editor = GetSubsystem<Editor>(); CurlRequest* request = (CurlRequest*) (eventData[CurlComplete::P_CURLREQUEST].GetPtr()); if (deactivate_.NotNull()) { assert(request == deactivate_); if (deactivate_->GetError().Length()) { String msg; msg.AppendWithFormat("Unable to deactivate with server: %s", deactivate_->GetError().CString()); editor->PostModalError("Deactivation Error", msg); LOGERROR(msg); } else { String response = request->GetResponse(); if (response.StartsWith("AC_FAILED")) { String msg; msg.AppendWithFormat("Unable to deactivate with server: %s", response.CString()); editor->PostModalError("Deactivation Error", msg); LOGERROR(msg); } else if (response.StartsWith("AC_NOTACTIVATED") || response.StartsWith("AC_SUCCESS")) { ResetLicense(); RemoveLicense(); UIModalOps* ops = GetSubsystem<UIModalOps>(); ops->Hide(); ops->ShowActivation(); } } UnsubscribeFromEvents(deactivate_); deactivate_ = 0; } }
void FromString<bool>::Function(String& out, bool& value, const String& string) { String head = string.SubString(0, 6).ToLower(); if (head.StartsWith("true")) { value = true; out = string.SubString(4); } else if (head.StartsWith("false")) { value = false; out = string.SubString(5); } else { out = string; } }
bool Pop3::PutGet(const String& s, bool multiline, bool nolog) { // Put() request. if(!s.IsEmpty()) { if(!nolog) LLOG(">> " << TrimRight(s)); if(!PutAll(s)) { LLOG("-- " << GetLastError()); return false; } } // Get() respone. data.Clear(); const int MAXLINE = 20000000; String line = GetLine(MAXLINE); if(!line.IsVoid()) { LLOG("<< " << TrimRight(line)); if(line.StartsWith("+OK")) { if(!multiline) { data.Cat(line); data.Cat("\r\n"); return true; } else for(;;) { line = GetLine(MAXLINE); if(line.IsVoid()) break; if(line == ".") { LLOG("<< ..."); return true; } data.Cat(*line == '.' ? line.Mid(1) : line); data.Cat("\r\n"); } } else if(line.StartsWith("-ERR")) error = line; } LLOG("-- " << GetLastError()); return false; }
void LicenseSystem::HandleDeactivate(StringHash eventType, VariantMap& eventData) { CurlRequest* request = (CurlRequest*) (eventData[CurlComplete::P_CURLREQUEST].GetPtr()); VariantMap eventDataOut; if (deactivate_.NotNull()) { assert(request == deactivate_); if (deactivate_->GetError().Length()) { String msg = "Deactivation Error:\n"; msg.AppendWithFormat("Unable to deactivate with server: %s", deactivate_->GetError().CString()); eventDataOut[LicenseDeactivationError::P_MESSAGE] = msg; SendEvent(E_LICENSE_DEACTIVATIONERROR, eventDataOut); } else { String response = request->GetResponse(); if (response.StartsWith("AC_FAILED")) { String msg = "Deactivation Error:\n"; msg.AppendWithFormat("Unable to deactivate with server: %s", response.CString()); eventDataOut[LicenseDeactivationError::P_MESSAGE] = msg; SendEvent(E_LICENSE_DEACTIVATIONERROR, eventDataOut); } else if (response.StartsWith("AC_NOTACTIVATED") || response.StartsWith("AC_SUCCESS")) { ResetLicense(); RemoveLicense(); SendEvent(E_LICENSE_DEACTIVATIONSUCCESS); } } UnsubscribeFromEvents(deactivate_); deactivate_ = 0; } }
long RendererDispatcher::FindURIPrefixInList(const String &requestURI, const ROAnything &uriPrefixList) { StartTrace(RendererDispatcher.FindURIPrefixInList); long apSz = uriPrefixList.GetSize(); for (long i = 0; i < apSz; ++i) { const char *uriPrefix = uriPrefixList.SlotName(i); if (uriPrefix && requestURI.StartsWith(uriPrefix)) { return i; } } return -1; }
AssetStoragePtr HttpAssetProvider::StorageForAssetRef(const String &assetRef) const { if (!IsValidRef(assetRef, "")) return AssetStoragePtr(); foreach(const AssetStoragePtr &httpStorage, httpStorages_) { if (assetRef.StartsWith(httpStorage->BaseURL(), true)) return httpStorage; } return AssetStoragePtr(); }
bool POP3ClientConnection::InternalParseData(const String &sRequest) { // This code is temporary home of ETRN client settings in GUI // It checks External Account for ETRN domain.com for name // and if found uses that info to perform ETRN client connections String sAccountName = account_->GetName(); if (sAccountName.StartsWith(_T("ETRN"))) { HandleEtrn_(sRequest, sAccountName); return true; } else { // No sense in indenting code below inward as this is temp // and it'd just have to be moved back. // **** Don't miss } below when removing the above code! **** LogPOP3String_(sRequest, false); bool bRetVal = true; switch (current_state_) { case StateConnected: ParseStateConnected_(sRequest); return true; case StateCAPASent: ParseStateCAPASent_(sRequest); return true; case StateSTLSSent: return ParseStateSTLSSent_(sRequest); case StateUsernameSent: ParseUsernameSent_(sRequest); return true; case StatePasswordSent: ParsePasswordSent_(sRequest); return true; case StateUIDLRequestSent: ParseUIDLResponse_(sRequest); return true; case StateQUITSent: return ParseQuitResponse_(sRequest); case StateDELESent: ParseDELEResponse_(sRequest); return true; } // This will be removed too when ETRN code is moved } return true; }
bool Shader::ProcessSource(String& code, Deserializer& source) { ResourceCache* cache = GetSubsystem<ResourceCache>(); // If the source if a non-packaged file, store the timestamp File* file = dynamic_cast<File*>(&source); if (file && !file->IsPackaged()) { FileSystem* fileSystem = GetSubsystem<FileSystem>(); String fullName = cache->GetResourceFileName(file->GetName()); unsigned fileTimeStamp = fileSystem->GetLastModifiedTime(fullName); if (fileTimeStamp > timeStamp_) timeStamp_ = fileTimeStamp; } // Store resource dependencies for includes so that we know to reload if any of them changes if (source.GetName() != GetName()) cache->StoreResourceDependency(this, source.GetName()); while (!source.IsEof()) { String line = source.ReadLine(); if (line.StartsWith("#include")) { String includeFileName = GetPath(source.GetName()) + line.Substring(9).Replaced("\"", "").Trimmed(); SharedPtr<File> includeFile = cache->GetFile(includeFileName); if (!includeFile) return false; // Add the include file into the current code recursively if (!ProcessSource(code, *includeFile)) return false; } else { code += line; code += "\n"; } } // Finally insert an empty line to mark the space between files code += "\n"; return true; }
Vector<AndroidVirtualDevice> AndroidSDK::FindVirtualDevices() const { Vector<AndroidVirtualDevice> avdes; String out; if(Sys(NormalizeExePath(AndroidPath()) + " list avd", out) == 0) { Vector<String> lines = Split(out, "\n"); AndroidVirtualDevice avd; for(int i = 0; i < lines.GetCount(); i++) { Vector<String> line = Split(lines[i], ":"); if(line.GetCount() == 2) { String tag = line[0]; String data = line[1]; if(data.StartsWith(" ")) data.Remove(0); if(tag.Find("Name") > -1) { if(!avd.GetName().IsEmpty() && avd.GetName() != data) avdes.Add(avd); avd.SetName(data); } else if(tag.Find("Device") > -1) avd.SetDeviceType(data); else if(tag.Find("Path") > -1) avd.SetPath(data); else if(tag.Find("Target") > -1) avd.SetTarget(data); else if(tag.Find("Tag/ABI") > -1) avd.SetAbi(data); // TODO: implement all possible tags } } if(!avd.GetName().IsEmpty()) avdes.Add(avd); } return avdes; }
bool MailImporter::GetRootLevelDirectory_(const String &fullPath, String &rootLevel) //---------------------------------------------------------------------------() // DESCRIPTION: // Takes an input parameter such as C:\DataDir\Account\Sub1\Sub2\Test.eml and // returns the root of that hierarcy, such as C:\Datadir\Account in this case. //---------------------------------------------------------------------------() { // The file must be located in the data directory. Make sure this is the case. const String dataDirectory = IniFileSettings::Instance()->GetDataDirectory(); if (!fullPath.StartsWith(dataDirectory)) return false; int currentTrimPosition = dataDirectory.GetLength() + 1; const String publicFolderName = IMAPConfiguration::GetPublicFolderDiskName(); // Is the file located in the public folder? if (fullPath.FindNoCase(publicFolderName, currentTrimPosition) == currentTrimPosition) { // The file is located in the public folder. currentTrimPosition += publicFolderName.GetLength() + 1; } else { // The file is either located in the queue folder or in an account folder. int slashPosition = fullPath.Find(_T("\\"), currentTrimPosition); if (slashPosition < 0) return false; int accountSlashPosition = fullPath.Find(_T("\\"), slashPosition+1); if (accountSlashPosition > 0) { // The file is locate din the queue folder. currentTrimPosition = accountSlashPosition+1; } } rootLevel = fullPath.Mid(0, currentTrimPosition); return true; }