UnicodeString getName(UnicodeString str) { UnicodeString name = str; if (name.Pos(":") > 0) name = name.SubString(1, name.Pos(":")-1); UnicodeString alphabet = L"QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890_"; while (true) { if (name.Length() == 0) break; UnicodeString ch = name.SubString(name.Length(), 1); if (alphabet.Pos(ch) > 0 && name.Length() > 0) break; name = name.SubString(1, name.Length()-1); } UnicodeString temp_name; while (true) { if (name.Length() == 0) break; UnicodeString ch = name.SubString(name.Length(), 1); if (alphabet.Pos(ch) > 0 && name.Length() > 0) temp_name = ch + temp_name; else break; name = name.SubString(1, name.Length()-1); } return temp_name; }
//--------------------------------------------------------------------------- UnicodeString MaskFileName(const UnicodeString & FileName, const UnicodeString & Mask) { UnicodeString Result = FileName; if (IsEffectiveFileNameMask(Mask)) { bool Masked; intptr_t P = Mask.LastDelimiter(L"."); if (P > 0) { intptr_t P2 = Result.LastDelimiter("."); // only dot at beginning of file name is not considered as // name/ext separator UnicodeString FileExt = P2 > 1 ? Result.SubString(P2 + 1, Result.Length() - P2) : UnicodeString(); FileExt = MaskFilePart(FileExt, Mask.SubString(P + 1, Mask.Length() - P), Masked); if (P2 > 1) { Result.SetLength(P2 - 1); } Result = MaskFilePart(Result, Mask.SubString(1, P - 1), Masked); if (!FileExt.IsEmpty()) { Result += L"." + FileExt; } } else { Result = MaskFilePart(Result, Mask, Masked); } } return Result; }
void TOptions::Add(const UnicodeString & Value) { if (!FNoMoreSwitches && (Value.Length() == 2) && (Value[1] == Value[2]) && (FSwitchMarks.Pos(Value[1]) > 0)) { FNoMoreSwitches = true; } else { bool Switch = false; intptr_t Index = 0; // shut up if (!FNoMoreSwitches && (Value.Length() >= 2) && (FSwitchMarks.Pos(Value[1]) > 0)) { Index = 2; Switch = true; while (Switch && (Index <= Value.Length())) { if (Value.IsDelimiter(FSwitchValueDelimiters, Index)) { break; } // this is to treat /home/martin as parameter, not as switch else if ((Value[Index] != L'?') && !IsLetter(Value[Index])) { Switch = false; break; } ++Index; } } if (Switch) { TOption Option; Option.Type = otSwitch; Option.Name = Value.SubString(2, Index - 2); Option.Value = Value.SubString(Index + 1, Value.Length()); Option.Used = false; FOptions.push_back(Option); } else { TOption Option; Option.Type = otParam; Option.Value = Value; Option.Used = false; FOptions.push_back(Option); ++FParamCount; } } FOriginalOptions = FOptions; }
// // Modifies the Filename's extension. The period is considered part // of the extension. // // "/foo/bar/baz.txt", ".dat" --> "/foo/bar/baz.dat" // "/foo/bar/baz.txt", "" --> "/foo/bar/baz" // "/foo/bar/baz", ".txt" --> "/foo/bar/baz.txt" // UnicodeString ChangeFileExtension(const UnicodeString & Path, const UnicodeString & Ext, wchar_t Delimiter) { UnicodeString FileName = ExtractFilename(Path, Delimiter); return ExtractDirectory(Path, Delimiter) + FileName.SubString(1, FileName.RPos(L'.')) + Ext; }
//--------------------------------------------------------------------- void __fastcall TFileSystemInfoDialog::ClipboardAddItem(TControl * Control, int Label, UnicodeString Value) { if (Control->Enabled && !Value.IsEmpty()) { if (FLastFeededControl != Control) { if (FLastFeededControl != NULL) { FClipboard += UnicodeString::StringOfChar(L'-', 60) + L"\r\n"; } FLastFeededControl = Control; } if (dynamic_cast<TListView *>(Control) == NULL) { TGroupBox * Group = dynamic_cast<TGroupBox *>(Control->Parent); assert(Group != NULL); if ((Value.Length() >= 2) && (Value.SubString(Value.Length() - 1, 2) == L"\r\n")) { Value.SetLength(Value.Length() - 2); } FClipboard += FORMAT(L"%s\r\n%s\r\n", (Group->Caption, Value)); } else { assert(dynamic_cast<TListView *>(Control) != NULL); FClipboard += FORMAT(L"%s = %s\r\n", (LoadStr(Label), Value)); } } }
void PrintDoc(seakgOutput *pOutput, UnicodeString filename, UnicodeString name, UnicodeString uuid, UnicodeString code) { filename = filename.SubString(rootPath.Length()+1, filename.Length() - rootPath.Length()); UnicodeString id = ""; // UnicodeString id = ""; code = encoding_html(code); name = encoding_html(name); TGUID g; OleCheck(CoCreateGuid(&g)); //Sysutils::GUIDToString(g); //id = Sysutils::GUIDToString(g); //id = id.SubString(2,37) + "[" + IntToStr(g_nInc++) + "]"; id = IntToStr(g_nInc++); while (id.Length() < 6) id = "0" + id; id = prefixforid + id; pOutput->addline("\t<doc>"); pOutput->addline("\t\t<field name=\"id\">" + id + "</field>"); pOutput->addline("\t\t<field name=\"project\">" + projectName + "</field>"); pOutput->addline("\t\t<field name=\"name\">" + name + "</field>"); pOutput->addline("\t\t<field name=\"uuid\">" + uuid.UpperCase() + "</field>"); pOutput->addline("\t\t<field name=\"source_filepath\">" + filename + "</field>"); pOutput->addline("\t\t<field name=\"full_source_code\">\n" + code + "\n\t\t</field>"); pOutput->addline("\t</doc>"); };
UnicodeString FileSearch(const UnicodeString & FileName, const UnicodeString & DirectoryList) { UnicodeString Temp; UnicodeString Result; Temp = DirectoryList; UnicodeString PathSeparators = L"/\\"; do { intptr_t I = ::Pos(Temp, PathSeparators); while ((Temp.Length() > 0) && (I == 0)) { Temp.Delete(1, 1); I = ::Pos(Temp, PathSeparators); } I = ::Pos(Temp, PathSeparators); if (I > 0) { Result = Temp.SubString(1, I - 1); Temp.Delete(1, I); } else { Result = Temp; Temp = L""; } Result = ::IncludeTrailingBackslash(Result); Result = Result + FileName; if (!::FileExists(Result)) { Result = L""; } } while (!(Temp.Length() == 0) || (Result.Length() != 0)); return Result; }
void __fastcall TResolution::SetByString(UnicodeString ResString) { int pos = Pos(L"x", ResString); if (pos == 0) throw EResolutionError(L"Divider not found"); try { this->Width = this->Convert(ResString.SubString(1, pos-1)); } catch (EResolutionError& e) { throw EResolutionError(UnicodeString(L"Cannot read width. ") + e.Message); } try { this->Height = this->Convert(ResString.SubString(pos+1, ResString.Length()-pos)); } catch (EResolutionError& e) { throw EResolutionError(UnicodeString(L"Cannot read height. ") + e.Message); } }
void ScanAndPrint(seakgOutput *pOutput, UnicodeString fullname) { TStringList *list = new TStringList(); list->LoadFromFile(fullname); int nCount = list->Count; for (int i = 0; i < nCount; i++) { UnicodeString str = list->Strings[i]; if (str.Pos(L"class") > 0 && str.Pos("__declspec") > 0) { UnicodeString code = str + "\r\n"; str = str.Trim(); UnicodeString uuid = "none"; if (str.Pos("\"") > 0) uuid = str.SubString(str.Pos("\"") + 1, 36); UnicodeString interfacename = str.SubString(str.Pos("I"), str.Length() - str.Pos("I") + 1); UnicodeString interfacename2 = getName(str); bool bStop = false; int nIncr = 0; while (bStop == false && i < nCount) { i++; str = list->Strings[i]; if (str.Pos("{") > 0) { nIncr++; }; if (str.Pos("}") > 0) { nIncr--; if(nIncr == 0) bStop = true; }; code += str + "\n"; }; PrintDoc(pOutput, fullname, interfacename2, uuid, code); // std::wcout << str.c_str(); }; }; /*std::wcout << "createuuidprojectname: " << << "\r\n"; std::wcout << "projectname: " << projectName.c_str() << "\r\n"; std::wcout << "fullname: " << fullname.c_str() << "\r\n";*/ };
//--------------------------------------------------------------------------- void __fastcall OpenBrowser(UnicodeString URL) { UnicodeString HomePageUrl = LoadStr(HOMEPAGE_URL); if (SameText(URL.SubString(1, HomePageUrl.Length()), HomePageUrl)) { URL = CampaignUrl(URL); } ShellExecute(Application->Handle, L"open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL); }
//--------------------------------------------------------------------------- UnicodeString __fastcall TConfiguration::TrimVersion(UnicodeString Version) { while ((Version.Pos(L".") != Version.LastDelimiter(L".")) && (Version.SubString(Version.Length() - 1, 2) == L".0")) { Version.SetLength(Version.Length() - 2); } return Version; }
static long OpenWinSCPKey(HKEY Key, const char * SubKey, HKEY * Result, bool CanCreate) { long R; assert(GetConfiguration() != nullptr); assert(Key == HKEY_CURRENT_USER); USEDPARAM(Key); UnicodeString RegKey = SubKey; UnicodeString OriginalPuttyRegistryStorageKey(_T(PUTTY_REG_POS)); intptr_t PuttyKeyLen = OriginalPuttyRegistryStorageKey.Length(); assert(RegKey.SubString(1, PuttyKeyLen) == OriginalPuttyRegistryStorageKey); RegKey = RegKey.SubString(PuttyKeyLen + 1, RegKey.Length() - PuttyKeyLen); if (!RegKey.IsEmpty()) { assert(RegKey[1] == L'\\'); RegKey.Delete(1, 1); } if (RegKey.IsEmpty()) { *Result = static_cast<HKEY>(nullptr); R = ERROR_SUCCESS; } else { // we expect this to be called only from verify_host_key() or store_host_key() assert(RegKey == L"SshHostKeys"); std::unique_ptr<THierarchicalStorage> Storage(GetConfiguration()->CreateConfigStorage()); Storage->SetAccessMode((CanCreate ? smReadWrite : smRead)); if (Storage->OpenSubKey(RegKey, CanCreate)) { *Result = reinterpret_cast<HKEY>(Storage.release()); R = ERROR_SUCCESS; } else { R = ERROR_CANTOPEN; } } return R; }
//--------------------------------------------------------------------------- static long OpenWinSCPKey(HKEY Key, const char * SubKey, HKEY * Result, bool CanCreate) { long R; assert(Configuration != NULL); assert(Key == HKEY_CURRENT_USER); USEDPARAM(Key); UnicodeString RegKey = SubKey; int PuttyKeyLen = OriginalPuttyRegistryStorageKey.Length(); assert(RegKey.SubString(1, PuttyKeyLen) == OriginalPuttyRegistryStorageKey); RegKey = RegKey.SubString(PuttyKeyLen + 1, RegKey.Length() - PuttyKeyLen); if (!RegKey.IsEmpty()) { assert(RegKey[1] == L'\\'); RegKey.Delete(1, 1); } if (RegKey.IsEmpty()) { *Result = static_cast<HKEY>(NULL); R = ERROR_SUCCESS; } else { // we expect this to be called only from verify_host_key() or store_host_key() assert(RegKey == L"SshHostKeys"); THierarchicalStorage * Storage = Configuration->CreateConfigStorage(); Storage->AccessMode = (CanCreate ? smReadWrite : smRead); if (Storage->OpenSubKey(RegKey, CanCreate)) { *Result = reinterpret_cast<HKEY>(Storage); R = ERROR_SUCCESS; } else { delete Storage; R = ERROR_CANTOPEN; } } return R; }
// // Returns the file's extension, if any. The period is considered part // of the extension. // // "/foo/bar/baz.txt" --> ".txt" // "/foo/bar/baz" --> "" UnicodeString ExtractFileExtension(const UnicodeString & Path, wchar_t Delimiter) { UnicodeString FileName = ExtractFilename(Path, Delimiter); intptr_t N = FileName.RPos(L'.'); if (N > 0) { return FileName.SubString(N); } return UnicodeString(); }
//--------------------------------------------------------------------------- UnicodeString TConfiguration::TrimVersion(const UnicodeString & Version) const { UnicodeString Result = Version; while ((Result.Pos(L".") != Result.LastDelimiter(L".")) && (Result.SubString(Result.Length() - 1, 2) == L".0")) { Result.SetLength(Result.Length() - 2); } return Result; }
//--------------------------------------------------------------------------- // TSrvResponse //--------------------------------------------------------------------------- __fastcall TSrvResponse::TSrvResponse(UnicodeString ResponseText) : TStringList() { if (ResponseText.IsEmpty()) throw ESrvResponseError(L"Server response is empty."); this->Text = ResponseText; try { this->StatusCode = StrToInt(this->Strings[0]); } catch (EConvertError& e) { throw ESrvResponseError(L"Cannot read status code. "+e.Message); } this->Delete(0); //Remove status code line for (int i = this->Count-1; i >= 0; i--) { UnicodeString line = this->Strings[i].Trim(); int split = line.Pos(L":"); if (split) { this->Strings[i] = line.SubString(1, split-1).Trim() \ + L":" \ + line.SubString(split+1, line.Length()-split).Trim(); } else { this->Delete(i); } } this->NameValueSeparator = ':'; if (this->StatusCode != 0) { if (this->StatusCode < 0) throw ESrvResponseError(L"Negative status code not allowed."); this->ErrorMessage = this->ReadString(TSrvResponseValID("ErrorMessage"), L"", true); if (this->ErrorMessage.IsEmpty()) this->ErrorMessage = L"Error #" + IntToStr(this->StatusCode) + L" (No error message provided)."; } else { //Find URLs this->AvatarURL = this->Values[L"AvatarURL"]; this->WatermarkURL = this->Values[L"WatermarkURL"]; } }
UnicodeString tabelaOpusa(UnicodeString Tabela) { if (Tabela.Pos("clienti_") == 0) return "clienti_"+Tabela; else { int pos = Tabela.Pos("_"); return Tabela.SubString(pos+1, Tabela.Length()-pos); } }
//--------------------------------------------------------------------------- bool TInteractiveCustomCommand::PatternReplacement(const UnicodeString & Pattern, UnicodeString & Replacement, bool & Delimit) { bool Result; if ((Pattern.Length() >= 3) && (Pattern[2] == L'?')) { UnicodeString PromptStr; intptr_t Pos = Pattern.SubString(3, Pattern.Length() - 2).Pos(L"?"); if (Pos > 0) { Replacement = Pattern.SubString(3 + Pos, Pattern.Length() - 3 - Pos); if ((Pos > 1) && (Pattern[3 + Pos - 2] == L'\\')) { Delimit = false; Pos--; } PromptStr = Pattern.SubString(3, Pos - 1); } else { PromptStr = Pattern.SubString(3, Pattern.Length() - 3); } Prompt(PromptStr, Replacement); Result = true; } else if ((Pattern.Length() >= 3) && (Pattern[2] == L'`')) { UnicodeString Command = Pattern.SubString(3, Pattern.Length() - 3); Command = FChildCustomCommand->Complete(Command, true); Execute(Command, Replacement); Delimit = false; Result = true; } else { Result = false; } return Result; }
UnicodeString TCopyParamType::ChangeFileName(const UnicodeString & AFileName, TOperationSide Side, bool FirstLevel) const { UnicodeString FileName = AFileName; if (FirstLevel) { FileName = MaskFileName(FileName, GetFileMask()); } switch (GetFileNameCase()) { case ncUpperCase: FileName = FileName.UpperCase(); break; case ncLowerCase: FileName = FileName.LowerCase(); break; case ncFirstUpperCase: FileName = FileName.SubString(1, 1).UpperCase() + FileName.SubString(2, FileName.Length() - 1).LowerCase(); break; case ncLowerCaseShort: if ((FileName.Length() <= 12) && (FileName.Pos(L".") <= 9) && (FileName == FileName.UpperCase())) { FileName = FileName.LowerCase(); } break; case ncNoChange: default: /*nothing*/ break; } if (Side == osRemote) { FileName = ValidLocalFileName(FileName); } else { FileName = RestoreChars(FileName); } return FileName; }
UnicodeString TrimLeft(const UnicodeString & Str) { UnicodeString Result = Str; intptr_t Len = Result.Length(); intptr_t Pos = 1; while ((Pos <= Len) && (Result[Pos] == L' ')) Pos++; if (Pos > 1) return Result.SubString(Pos, Len - Pos + 1); else return Result; }
UnicodeString TCopyParamType::RestoreChars(const UnicodeString & AFileName) const { UnicodeString FileName = AFileName; if (GetInvalidCharsReplacement() == TokenReplacement) { wchar_t * InvalidChar = const_cast<wchar_t *>(FileName.c_str()); while ((InvalidChar = wcschr(InvalidChar, TokenPrefix)) != nullptr) { intptr_t Index = InvalidChar - FileName.c_str() + 1; if (FileName.Length() >= Index + 2) { UnicodeString Hex = FileName.SubString(Index + 1, 2); wchar_t Char = static_cast<wchar_t>(HexToByte(Hex)); if ((Char != L'\0') && ((FTokenizibleChars.Pos(Char) > 0) || (((Char == L' ') || (Char == L'.')) && (Index == FileName.Length() - 2)))) { FileName[Index] = Char; FileName.Delete(Index + 1, 2); InvalidChar = const_cast<wchar_t *>(FileName.c_str() + Index); } else if ((Hex == L"00") && ((Index == FileName.Length() - 2) || (FileName[Index + 3] == L'.')) && IsReservedName(FileName.SubString(1, Index - 1) + FileName.SubString(Index + 3, FileName.Length() - Index - 3 + 1))) { FileName.Delete(Index, 3); InvalidChar = const_cast<wchar_t *>(FileName.c_str() + Index - 1); } else { InvalidChar++; } } else { InvalidChar++; } } } return FileName; }
UnicodeString ExtractFileDir(const UnicodeString & Str) { UnicodeString Result; intptr_t Pos = Str.LastDelimiter(L"/\\"); // it used to return Path when no slash was found if (Pos > 0) { Result = Str.SubString(1, Pos); } else { Result = (Pos == 1) ? UnicodeString(L"/") : UnicodeString(); } return Result; }
//--------------------------------------------------------------------------- UnicodeString MaskFilePart(const UnicodeString & Part, const UnicodeString & Mask, bool & Masked) { UnicodeString Result; intptr_t RestStart = 1; bool Delim = false; for (intptr_t Index = 1; Index <= Mask.Length(); ++Index) { switch (Mask[Index]) { case L'\\': if (!Delim) { Delim = true; Masked = true; break; } case L'*': if (!Delim) { Result += Part.SubString(RestStart, Part.Length() - RestStart + 1); RestStart = Part.Length() + 1; Masked = true; break; } case L'?': if (!Delim) { if (RestStart <= Part.Length()) { Result += Part[RestStart]; RestStart++; } Masked = true; break; } default: Result += Mask[Index]; RestStart++; Delim = false; break; } } return Result; }
//--------------------------------------------------------------------------- void __fastcall TFileFindDialog::FileFound(TTerminal * /*Terminal*/, const UnicodeString FileName, const TRemoteFile * AFile, bool & Cancel) { TListItem * Item = FileView->Items->Add(); TRemoteFile * File = AFile->Duplicate(true); Item->Data = File; Item->ImageIndex = File->IconIndex; UnicodeString Caption = File->FileName; if (File->IsDirectory) { Caption = UnixIncludeTrailingBackslash(Caption); } Item->Caption = Caption; UnicodeString Directory = UnixExtractFilePath(File->FullFileName); if (AnsiSameText(FDirectory, Directory.SubString(1, FDirectory.Length()))) { Directory[1] = L'.'; Directory.Delete(2, FDirectory.Length() - 1); } else { assert(false); } Item->SubItems->Add(Directory); if (File->IsDirectory) { Item->SubItems->Add(L""); } else { Item->SubItems->Add( FormatBytes(File->Size, WinConfiguration->FormatSizeBytes, WinConfiguration->FormatSizeBytes)); } Item->SubItems->Add(UserModificationStr(File->Modification, File->ModificationFmt)); UpdateControls(); Cancel = (FState == ffAborting); Application->ProcessMessages(); }
//--------------------------------------------------------------------------- void __fastcall Usage(UnicodeString Param) { while (!Param.IsEmpty()) { UnicodeString Pair = ::CutToChar(Param, L',', true); if (!Pair.IsEmpty()) { if (Pair[Pair.Length()] == L'+') { UnicodeString Key = Pair.SubString(1, Pair.Length() - 1).Trim(); Configuration->Usage->Inc(Key); } else { UnicodeString Key = ::CutToChar(Pair, L':', true); Configuration->Usage->Set(Key, Pair.Trim()); } } } }
UnicodeString TConfiguration::PropertyToKey(const UnicodeString & Property) { // no longer useful intptr_t P = Property.LastDelimiter(L".>"); return Property.SubString(P + 1, Property.Length() - P); }
// // Returns only the Filename part of the Path. // // "/foo/bar/baz.txt" --> "baz.txt" UnicodeString ExtractFilename(const UnicodeString & Path, wchar_t Delimiter) { return Path.SubString(Path.RPos(Delimiter) + 1); }
// // Returns everything, including the trailing Path separator, except the Filename // part of the Path. // // "/foo/bar/baz.txt" --> "/foo/bar/" UnicodeString ExtractDirectory(const UnicodeString & Path, wchar_t Delimiter) { return Path.SubString(1, Path.RPos(Delimiter) + 1); }
//--------------------------------------------------------------------------- UnicodeString TCustomCommand::Complete(const UnicodeString & Command, bool LastPass) { UnicodeString Result; intptr_t Index = 1; while (Index <= Command.Length()) { intptr_t Len; wchar_t PatternCmd; GetToken(Command, Index, Len, PatternCmd); if (PatternCmd == TEXT_TOKEN) { Result += Command.SubString(Index, Len); } else if (PatternCmd == L'!') { if (LastPass) { Result += L'!'; } else { Result += Command.SubString(Index, Len); } } else { wchar_t Quote = NoQuote; if ((Index > 1) && (Index + Len - 1 < Command.Length()) && Command.IsDelimiter(Quotes, Index - 1) && Command.IsDelimiter(Quotes, Index + Len) && (Command[Index - 1] == Command[Index + Len])) { Quote = Command[Index - 1]; } UnicodeString Pattern = Command.SubString(Index, Len); UnicodeString Replacement; bool Delimit = true; if (PatternReplacement(Pattern, Replacement, Delimit)) { if (!LastPass) { Replacement = StringReplace(Replacement, L"!", L"!!", TReplaceFlags() << rfReplaceAll); } if (Delimit) { DelimitReplacement(Replacement, Quote); } Result += Replacement; } else { Result += Pattern; } } Index += Len; } return Result; }
//--------------------------------------------------------------------------- void TFileMasks::CreateMask( const UnicodeString & MaskStr, intptr_t MaskStart, intptr_t /*MaskEnd*/, bool Include) { bool Directory = false; // shut up TMask Mask; Mask.MaskStr = MaskStr; Mask.UserStr = MaskStr; Mask.FileNameMask.Kind = TMaskMask::Any; Mask.FileNameMask.Mask = nullptr; Mask.DirectoryMask.Kind = TMaskMask::Any; Mask.DirectoryMask.Mask = nullptr; Mask.HighSizeMask = TMask::None; Mask.LowSizeMask = TMask::None; Mask.HighModificationMask = TMask::None; Mask.LowModificationMask = TMask::None; wchar_t NextPartDelimiter = L'\0'; intptr_t NextPartFrom = 1; while (NextPartFrom <= MaskStr.Length()) { wchar_t PartDelimiter = NextPartDelimiter; intptr_t PartFrom = NextPartFrom; UnicodeString PartStr = CopyToChars(MaskStr, NextPartFrom, L"<>", false, &NextPartDelimiter, true); intptr_t PartStart = MaskStart + PartFrom - 1; intptr_t PartEnd = MaskStart + NextPartFrom - 1 - 2; TrimEx(PartStr, PartStart, PartEnd); if (PartDelimiter != L'\0') { bool Low = (PartDelimiter == L'>'); TMask::TMaskBoundary Boundary; if ((PartStr.Length() >= 1) && (PartStr[1] == L'=')) { Boundary = TMask::Close; PartStr.Delete(1, 1); } else { Boundary = TMask::Open; } TFormatSettings FormatSettings = TFormatSettings::Create(GetDefaultLCID()); FormatSettings.DateSeparator = L'-'; FormatSettings.TimeSeparator = L':'; FormatSettings.ShortDateFormat = L"yyyy/mm/dd"; FormatSettings.ShortTimeFormat = L"hh:nn:ss"; TDateTime Modification; if (TryStrToDateTime(PartStr, Modification, FormatSettings) || TryRelativeStrToDateTime(PartStr, Modification)) { TMask::TMaskBoundary & ModificationMask = (Low ? Mask.LowModificationMask : Mask.HighModificationMask); if ((ModificationMask != TMask::None) || Directory) { // include delimiter into size part ThrowError(PartStart - 1, PartEnd); } ModificationMask = Boundary; (Low ? Mask.LowModification : Mask.HighModification) = Modification; } else { TMask::TMaskBoundary & SizeMask = (Low ? Mask.LowSizeMask : Mask.HighSizeMask); __int64 & Size = (Low ? Mask.LowSize : Mask.HighSize); if ((SizeMask != TMask::None) || Directory) { // include delimiter into size part ThrowError(PartStart - 1, PartEnd); } SizeMask = Boundary; Size = ParseSize(PartStr); } } else if (!PartStr.IsEmpty()) { intptr_t D = PartStr.LastDelimiter(DirectoryMaskDelimiters); Directory = (D > 0) && (D == PartStr.Length()); if (Directory) { do { PartStr.SetLength(PartStr.Length() - 1); Mask.UserStr.Delete(PartStart - MaskStart + D, 1); D--; } while (PartStr.IsDelimiter(DirectoryMaskDelimiters, PartStr.Length())); D = PartStr.LastDelimiter(DirectoryMaskDelimiters); if (FForceDirectoryMasks == 0) { Directory = false; Mask.MaskStr = Mask.UserStr; } } else if (FForceDirectoryMasks > 0) { Directory = true; Mask.MaskStr.Insert(DirectoryMaskDelimiters[1], PartStart - MaskStart + PartStr.Length()); } if (D > 0) { // make sure sole "/" (root dir) is preserved as is CreateMaskMask( UnixExcludeTrailingBackslash(ToUnixPath(PartStr.SubString(1, D))), PartStart, PartStart + D - 1, false, Mask.DirectoryMask); CreateMaskMask( PartStr.SubString(D + 1, PartStr.Length() - D), PartStart + D, PartEnd, true, Mask.FileNameMask); } else { CreateMaskMask(PartStr, PartStart, PartEnd, true, Mask.FileNameMask); } } } FMasks[MASK_INDEX(Directory, Include)].push_back(Mask); }