GUITools.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. //---------------------------------------------------------------------------
  2. #define NO_WIN32_LEAN_AND_MEAN
  3. #include <vcl.h>
  4. #pragma hdrstop
  5. #include <shlobj.h>
  6. #include <Common.h>
  7. #include "GUITools.h"
  8. #include "GUIConfiguration.h"
  9. #include <TextsCore.h>
  10. #include <CoreMain.h>
  11. #include <SessionData.h>
  12. #include <WinInterface.h>
  13. #include <TbxUtils.hpp>
  14. #include <Math.hpp>
  15. #include "PngImageList.hpp"
  16. //---------------------------------------------------------------------------
  17. #pragma package(smart_init)
  18. //---------------------------------------------------------------------------
  19. extern const UnicodeString PageantTool = L"pageant.exe";
  20. extern const UnicodeString PuttygenTool = L"puttygen.exe";
  21. //---------------------------------------------------------------------------
  22. bool __fastcall FindFile(UnicodeString & Path)
  23. {
  24. bool Result = FileExists(Path);
  25. if (!Result)
  26. {
  27. int Len = GetEnvironmentVariable(L"PATH", NULL, 0);
  28. if (Len > 0)
  29. {
  30. UnicodeString Paths;
  31. Paths.SetLength(Len - 1);
  32. GetEnvironmentVariable(L"PATH", Paths.c_str(), Len);
  33. UnicodeString NewPath = FileSearch(ExtractFileName(Path), Paths);
  34. Result = !NewPath.IsEmpty();
  35. if (Result)
  36. {
  37. Path = NewPath;
  38. }
  39. }
  40. }
  41. return Result;
  42. }
  43. //---------------------------------------------------------------------------
  44. bool __fastcall FileExistsEx(UnicodeString Path)
  45. {
  46. return FindFile(Path);
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall OpenSessionInPutty(const UnicodeString PuttyPath,
  50. TSessionData * SessionData, UnicodeString UserName, UnicodeString Password)
  51. {
  52. UnicodeString Program, AParams, Dir;
  53. SplitCommand(PuttyPath, Program, AParams, Dir);
  54. Program = ExpandEnvironmentVariables(Program);
  55. if (FindFile(Program))
  56. {
  57. AParams = ExpandEnvironmentVariables(AParams);
  58. TCustomCommandData Data(SessionData, UserName, Password);
  59. TRemoteCustomCommand RemoteCustomCommand(Data, SessionData->RemoteDirectory);
  60. TWinInteractiveCustomCommand InteractiveCustomCommand(
  61. &RemoteCustomCommand, L"PuTTY");
  62. UnicodeString Params =
  63. RemoteCustomCommand.Complete(InteractiveCustomCommand.Complete(AParams, false), true);
  64. if (!RemoteCustomCommand.IsSiteCommand(AParams))
  65. {
  66. UnicodeString SessionName;
  67. TRegistryStorage * Storage = NULL;
  68. TSessionData * ExportData = NULL;
  69. TRegistryStorage * SourceStorage = NULL;
  70. try
  71. {
  72. Storage = new TRegistryStorage(Configuration->PuttySessionsKey);
  73. Storage->AccessMode = smReadWrite;
  74. // make it compatible with putty
  75. Storage->MungeStringValues = false;
  76. Storage->ForceAnsi = true;
  77. if (Storage->OpenRootKey(true))
  78. {
  79. if (Storage->KeyExists(SessionData->StorageKey))
  80. {
  81. SessionName = SessionData->SessionName;
  82. }
  83. else
  84. {
  85. SourceStorage = new TRegistryStorage(Configuration->PuttySessionsKey);
  86. SourceStorage->MungeStringValues = false;
  87. SourceStorage->ForceAnsi = true;
  88. if (SourceStorage->OpenSubKey(StoredSessions->DefaultSettings->Name, false) &&
  89. Storage->OpenSubKey(GUIConfiguration->PuttySession, true))
  90. {
  91. Storage->Copy(SourceStorage);
  92. Storage->CloseSubKey();
  93. }
  94. ExportData = new TSessionData(L"");
  95. ExportData->Assign(SessionData);
  96. ExportData->Modified = true;
  97. ExportData->Name = GUIConfiguration->PuttySession;
  98. ExportData->Password = L"";
  99. if (SessionData->FSProtocol == fsFTP)
  100. {
  101. if (GUIConfiguration->TelnetForFtpInPutty)
  102. {
  103. ExportData->PuttyProtocol = PuttyTelnetProtocol;
  104. ExportData->PortNumber = TelnetPortNumber;
  105. // PuTTY does not allow -pw for telnet
  106. Password = L"";
  107. }
  108. else
  109. {
  110. ExportData->PuttyProtocol = PuttySshProtocol;
  111. ExportData->PortNumber = SshPortNumber;
  112. }
  113. }
  114. ExportData->Save(Storage, true);
  115. SessionName = GUIConfiguration->PuttySession;
  116. }
  117. }
  118. }
  119. __finally
  120. {
  121. delete Storage;
  122. delete ExportData;
  123. delete SourceStorage;
  124. }
  125. AddToList(Params, FORMAT(L"-load %s", (EscapePuttyCommandParam(SessionName))), L" ");
  126. }
  127. if (!Password.IsEmpty() && !RemoteCustomCommand.IsPasswordCommand(AParams))
  128. {
  129. AddToList(Params, FORMAT(L"-pw %s", (EscapePuttyCommandParam(Password))), L" ");
  130. }
  131. if (!ExecuteShell(Program, Params))
  132. {
  133. throw Exception(FMTLOAD(EXECUTE_APP_ERROR, (Program)));
  134. }
  135. }
  136. else
  137. {
  138. throw Exception(FMTLOAD(FILE_NOT_FOUND, (Program)));
  139. }
  140. }
  141. //---------------------------------------------------------------------------
  142. bool __fastcall FindTool(const UnicodeString & Name, UnicodeString & Path)
  143. {
  144. UnicodeString AppPath = IncludeTrailingBackslash(ExtractFilePath(Application->ExeName));
  145. Path = AppPath + Name;
  146. bool Result = true;
  147. if (!FileExists(Path))
  148. {
  149. Path = AppPath + L"PuTTY\\" + Name;
  150. if (!FileExists(Path))
  151. {
  152. Path = Name;
  153. if (!FindFile(Path))
  154. {
  155. Result = false;
  156. }
  157. }
  158. }
  159. return Result;
  160. }
  161. //---------------------------------------------------------------------------
  162. bool __fastcall ExecuteShell(const UnicodeString Path, const UnicodeString Params)
  163. {
  164. return ((int)ShellExecute(NULL, L"open", (wchar_t*)Path.data(),
  165. (wchar_t*)Params.data(), NULL, SW_SHOWNORMAL) > 32);
  166. }
  167. //---------------------------------------------------------------------------
  168. bool __fastcall ExecuteShell(const UnicodeString Path, const UnicodeString Params,
  169. HANDLE & Handle)
  170. {
  171. bool Result;
  172. TShellExecuteInfoW ExecuteInfo;
  173. memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));
  174. ExecuteInfo.cbSize = sizeof(ExecuteInfo);
  175. ExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
  176. ExecuteInfo.hwnd = Application->Handle;
  177. ExecuteInfo.lpFile = (wchar_t*)Path.data();
  178. ExecuteInfo.lpParameters = (wchar_t*)Params.data();
  179. ExecuteInfo.nShow = SW_SHOW;
  180. Result = (ShellExecuteEx(&ExecuteInfo) != 0);
  181. if (Result)
  182. {
  183. Handle = ExecuteInfo.hProcess;
  184. }
  185. return Result;
  186. }
  187. //---------------------------------------------------------------------------
  188. bool __fastcall ExecuteShellAndWait(HWND Handle, const UnicodeString Path,
  189. const UnicodeString Params, TProcessMessagesEvent ProcessMessages)
  190. {
  191. bool Result;
  192. TShellExecuteInfoW ExecuteInfo;
  193. memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));
  194. ExecuteInfo.cbSize = sizeof(ExecuteInfo);
  195. ExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
  196. ExecuteInfo.hwnd = Handle;
  197. ExecuteInfo.lpFile = (wchar_t*)Path.data();
  198. ExecuteInfo.lpParameters = (wchar_t*)Params.data();
  199. ExecuteInfo.nShow = SW_SHOW;
  200. Result = (ShellExecuteEx(&ExecuteInfo) != 0);
  201. if (Result)
  202. {
  203. if (ProcessMessages != NULL)
  204. {
  205. unsigned long WaitResult;
  206. do
  207. {
  208. WaitResult = WaitForSingleObject(ExecuteInfo.hProcess, 200);
  209. if (WaitResult == WAIT_FAILED)
  210. {
  211. throw Exception(LoadStr(DOCUMENT_WAIT_ERROR));
  212. }
  213. ProcessMessages();
  214. }
  215. while (WaitResult == WAIT_TIMEOUT);
  216. }
  217. else
  218. {
  219. WaitForSingleObject(ExecuteInfo.hProcess, INFINITE);
  220. }
  221. }
  222. return Result;
  223. }
  224. //---------------------------------------------------------------------------
  225. bool __fastcall ExecuteShellAndWait(HWND Handle, const UnicodeString Command,
  226. TProcessMessagesEvent ProcessMessages)
  227. {
  228. UnicodeString Program, Params, Dir;
  229. SplitCommand(Command, Program, Params, Dir);
  230. return ExecuteShellAndWait(Handle, Program, Params, ProcessMessages);
  231. }
  232. //---------------------------------------------------------------------------
  233. bool __fastcall SpecialFolderLocation(int PathID, UnicodeString & Path)
  234. {
  235. LPITEMIDLIST Pidl;
  236. wchar_t Buf[256];
  237. if (SHGetSpecialFolderLocation(NULL, PathID, &Pidl) == NO_ERROR &&
  238. SHGetPathFromIDList(Pidl, Buf))
  239. {
  240. Path = UnicodeString(Buf);
  241. return true;
  242. }
  243. return false;
  244. }
  245. //---------------------------------------------------------------------------
  246. UnicodeString __fastcall GetPersonalFolder()
  247. {
  248. UnicodeString Result;
  249. SpecialFolderLocation(CSIDL_PERSONAL, Result);
  250. if (IsWine())
  251. {
  252. UnicodeString WineHostHome = GetEnvironmentVariable(L"WINE_HOST_HOME");
  253. if (!WineHostHome.IsEmpty())
  254. {
  255. UnicodeString WineHome = L"Z:" + ToUnixPath(WineHostHome);
  256. if (DirectoryExists(WineHome))
  257. {
  258. Result = WineHome;
  259. }
  260. }
  261. else
  262. {
  263. // Should we use WinAPI GetUserName() instead?
  264. UnicodeString UserName = GetEnvironmentVariable(L"USERNAME");
  265. if (!UserName.IsEmpty())
  266. {
  267. UnicodeString WineHome = L"Z:\\home\\" + UserName;
  268. if (DirectoryExists(WineHome))
  269. {
  270. Result = WineHome;
  271. }
  272. }
  273. }
  274. }
  275. return Result;
  276. }
  277. //---------------------------------------------------------------------------
  278. UnicodeString __fastcall ItemsFormatString(const UnicodeString SingleItemFormat,
  279. const UnicodeString MultiItemsFormat, int Count, const UnicodeString FirstItem)
  280. {
  281. UnicodeString Result;
  282. if (Count == 1)
  283. {
  284. Result = FORMAT(SingleItemFormat, (FirstItem));
  285. }
  286. else
  287. {
  288. Result = FORMAT(MultiItemsFormat, (Count));
  289. }
  290. return Result;
  291. }
  292. //---------------------------------------------------------------------------
  293. UnicodeString __fastcall ItemsFormatString(const UnicodeString SingleItemFormat,
  294. const UnicodeString MultiItemsFormat, TStrings * Items)
  295. {
  296. return ItemsFormatString(SingleItemFormat, MultiItemsFormat,
  297. Items->Count, (Items->Count > 0 ? Items->Strings[0] : UnicodeString()));
  298. }
  299. //---------------------------------------------------------------------------
  300. UnicodeString __fastcall FileNameFormatString(const UnicodeString SingleFileFormat,
  301. const UnicodeString MultiFilesFormat, TStrings * Files, bool Remote)
  302. {
  303. assert(Files != NULL);
  304. UnicodeString Item;
  305. if (Files->Count > 0)
  306. {
  307. Item = Remote ? UnixExtractFileName(Files->Strings[0]) :
  308. ExtractFileName(Files->Strings[0]);
  309. }
  310. return ItemsFormatString(SingleFileFormat, MultiFilesFormat,
  311. Files->Count, Item);
  312. }
  313. //---------------------------------------------------------------------------
  314. UnicodeString __fastcall UniqTempDir(const UnicodeString BaseDir, const UnicodeString Identity,
  315. bool Mask)
  316. {
  317. UnicodeString TempDir;
  318. do
  319. {
  320. TempDir = BaseDir.IsEmpty() ? SystemTemporaryDirectory() : BaseDir;
  321. TempDir = IncludeTrailingBackslash(TempDir) + Identity;
  322. if (Mask)
  323. {
  324. TempDir += L"?????";
  325. }
  326. else
  327. {
  328. TempDir += IncludeTrailingBackslash(FormatDateTime(L"nnzzz", Now()));
  329. };
  330. }
  331. while (!Mask && DirectoryExists(TempDir));
  332. return TempDir;
  333. }
  334. //---------------------------------------------------------------------------
  335. bool __fastcall DeleteDirectory(const UnicodeString DirName)
  336. {
  337. TSearchRecChecked sr;
  338. bool retval = true;
  339. if (FindFirstUnchecked(DirName + L"\\*", faAnyFile, sr) == 0) // VCL Function
  340. {
  341. if (FLAGSET(sr.Attr, faDirectory))
  342. {
  343. if (sr.Name != L"." && sr.Name != L"..")
  344. retval = DeleteDirectory(DirName + L"\\" + sr.Name);
  345. }
  346. else
  347. {
  348. retval = DeleteFile(DirName + L"\\" + sr.Name);
  349. }
  350. if (retval)
  351. {
  352. while (FindNextChecked(sr) == 0)
  353. { // VCL Function
  354. if (FLAGSET(sr.Attr, faDirectory))
  355. {
  356. if (sr.Name != L"." && sr.Name != L"..")
  357. retval = DeleteDirectory(DirName + L"\\" + sr.Name);
  358. }
  359. else
  360. {
  361. retval = DeleteFile(DirName + L"\\" + sr.Name);
  362. }
  363. if (!retval) break;
  364. }
  365. }
  366. }
  367. FindClose(sr);
  368. if (retval) retval = RemoveDir(DirName); // VCL function
  369. return retval;
  370. }
  371. //---------------------------------------------------------------------------
  372. UnicodeString __fastcall FormatDateTimeSpan(const UnicodeString TimeFormat, TDateTime DateTime)
  373. {
  374. UnicodeString Result;
  375. if (int(DateTime) > 0)
  376. {
  377. Result = IntToStr(int(DateTime)) + L", ";
  378. }
  379. // days are decremented, because when there are to many of them,
  380. // "integer overflow" error occurs
  381. Result += FormatDateTime(TimeFormat, DateTime - int(DateTime));
  382. return Result;
  383. }
  384. //---------------------------------------------------------------------------
  385. void __fastcall AddSessionColorImage(
  386. TCustomImageList * ImageList, TColor Color, int MaskIndex)
  387. {
  388. // This overly complex drawing is here to support color button on SiteAdvanced
  389. // dialog. There we use plain TImageList, instead of TPngImageList,
  390. // TButton does not work with transparent images
  391. // (not even TBitmap with Transparent = true)
  392. std::unique_ptr<TBitmap> MaskBitmap(new TBitmap());
  393. ImageList->GetBitmap(MaskIndex, MaskBitmap.get());
  394. std::unique_ptr<TPngImage> MaskImage(new TPngImage());
  395. MaskImage->Assign(MaskBitmap.get());
  396. std::unique_ptr<TPngImage> ColorImage(new TPngImage(COLOR_RGB, 16, ImageList->Width, ImageList->Height));
  397. TColor MaskTransparentColor = MaskImage->Pixels[0][0];
  398. TColor TransparentColor = MaskTransparentColor;
  399. // Expecting that the color to be replaced is in the centre of the image (HACK)
  400. TColor MaskColor = MaskImage->Pixels[ImageList->Width / 2][ImageList->Height / 2];
  401. for (int Y = 0; Y < ImageList->Height; Y++)
  402. {
  403. for (int X = 0; X < ImageList->Width; X++)
  404. {
  405. TColor SourceColor = MaskImage->Pixels[X][Y];
  406. TColor DestColor;
  407. // this branch is pointless as long as MaskTransparentColor and
  408. // TransparentColor are the same
  409. if (SourceColor == MaskTransparentColor)
  410. {
  411. DestColor = TransparentColor;
  412. }
  413. else if (SourceColor == MaskColor)
  414. {
  415. DestColor = Color;
  416. }
  417. else
  418. {
  419. DestColor = SourceColor;
  420. }
  421. ColorImage->Pixels[X][Y] = DestColor;
  422. }
  423. }
  424. std::unique_ptr<TBitmap> Bitmap(new TBitmap());
  425. Bitmap->SetSize(ImageList->Width, ImageList->Height);
  426. ColorImage->AssignTo(Bitmap.get());
  427. ImageList->AddMasked(Bitmap.get(), TransparentColor);
  428. }
  429. //---------------------------------------------------------------------------
  430. bool __fastcall IsEligibleForApplyingTabs(
  431. UnicodeString Line, int & TabPos, UnicodeString & Start, UnicodeString & Remaining)
  432. {
  433. bool Result = false;
  434. TabPos = Line.Pos(L"\t");
  435. if (TabPos > 0)
  436. {
  437. Remaining = Line.SubString(TabPos + 1, Line.Length() - TabPos);
  438. // WORKAROUND
  439. // Some translations still use obsolete hack of consecutive tabs to aling the contents.
  440. // Delete these, so that the following check does not fail on this
  441. while (Remaining.SubString(1, 1) == L"\t")
  442. {
  443. Remaining.Delete(1, 1);
  444. }
  445. // We do not have, not support, mutiple tabs on a single line
  446. if (ALWAYS_TRUE(Remaining.Pos(L"\t") == 0))
  447. {
  448. Start = Line.SubString(1, TabPos - 1);
  449. // WORKAROUND
  450. // Previously we padded the string before tab with spaces,
  451. // to aling the contents across multiple lines
  452. Start = Start.TrimRight();
  453. // at least two normal spaces for separation
  454. Start += L" ";
  455. Result = true;
  456. }
  457. }
  458. return Result;
  459. }
  460. //---------------------------------------------------------------------------
  461. static int __fastcall CalculateWidthByLength(UnicodeString Text, void * /*Arg*/)
  462. {
  463. return Text.Length();
  464. }
  465. //---------------------------------------------------------------------------
  466. void __fastcall ApplyTabs(
  467. UnicodeString & Text, wchar_t Padding,
  468. TCalculateWidth CalculateWidth, void * CalculateWidthArg)
  469. {
  470. if (CalculateWidth == NULL)
  471. {
  472. assert(CalculateWidthArg == NULL);
  473. CalculateWidth = CalculateWidthByLength;
  474. }
  475. std::unique_ptr<TStringList> Lines(new TStringList());
  476. Lines->Text = Text;
  477. int MaxWidth = -1;
  478. for (int Index = 0; Index < Lines->Count; Index++)
  479. {
  480. UnicodeString Line = Lines->Strings[Index];
  481. int TabPos;
  482. UnicodeString Start;
  483. UnicodeString Remaining;
  484. if (IsEligibleForApplyingTabs(Line, TabPos, Start, Remaining))
  485. {
  486. int Width = CalculateWidth(Start, CalculateWidthArg);
  487. MaxWidth = Max(MaxWidth, Width);
  488. }
  489. }
  490. // Optimization and also to prevent potential regression for texts without tabs
  491. if (MaxWidth >= 0)
  492. {
  493. for (int Index = 0; Index < Lines->Count; Index++)
  494. {
  495. UnicodeString Line = Lines->Strings[Index];
  496. int TabPos;
  497. UnicodeString Start;
  498. UnicodeString Remaining;
  499. if (IsEligibleForApplyingTabs(Line, TabPos, Start, Remaining))
  500. {
  501. int Width;
  502. while ((Width = CalculateWidth(Start, CalculateWidthArg)) < MaxWidth)
  503. {
  504. int Wider = CalculateWidth(Start + Padding, CalculateWidthArg);
  505. // If padded string is wider than max width by more pixels
  506. // than non-padded string is shorter than max width
  507. if ((Wider > MaxWidth) && ((Wider - MaxWidth) > (MaxWidth - Width)))
  508. {
  509. break;
  510. }
  511. Start += Padding;
  512. }
  513. Lines->Strings[Index] = Start + Remaining;
  514. }
  515. }
  516. Text = Lines->Text;
  517. // remove trailing newline
  518. Text = Text.TrimRight();
  519. }
  520. }
  521. //---------------------------------------------------------------------------
  522. TLocalCustomCommand::TLocalCustomCommand()
  523. {
  524. }
  525. //---------------------------------------------------------------------------
  526. TLocalCustomCommand::TLocalCustomCommand(const TCustomCommandData & Data,
  527. const UnicodeString & Path) :
  528. TFileCustomCommand(Data, Path)
  529. {
  530. }
  531. //---------------------------------------------------------------------------
  532. TLocalCustomCommand::TLocalCustomCommand(const TCustomCommandData & Data,
  533. const UnicodeString & Path, const UnicodeString & FileName,
  534. const UnicodeString & LocalFileName, const UnicodeString & FileList) :
  535. TFileCustomCommand(Data, Path, FileName, FileList)
  536. {
  537. FLocalFileName = LocalFileName;
  538. }
  539. //---------------------------------------------------------------------------
  540. int __fastcall TLocalCustomCommand::PatternLen(const UnicodeString & Command, int Index)
  541. {
  542. int Len;
  543. if ((Index < Command.Length()) && (Command[Index + 1] == L'^'))
  544. {
  545. Len = 3;
  546. }
  547. else
  548. {
  549. Len = TFileCustomCommand::PatternLen(Command, Index);
  550. }
  551. return Len;
  552. }
  553. //---------------------------------------------------------------------------
  554. bool __fastcall TLocalCustomCommand::PatternReplacement(
  555. const UnicodeString & Pattern, UnicodeString & Replacement, bool & Delimit)
  556. {
  557. bool Result;
  558. if (Pattern == L"!^!")
  559. {
  560. Replacement = FLocalFileName;
  561. Result = true;
  562. }
  563. else
  564. {
  565. Result = TFileCustomCommand::PatternReplacement(Pattern, Replacement, Delimit);
  566. }
  567. return Result;
  568. }
  569. //---------------------------------------------------------------------------
  570. void __fastcall TLocalCustomCommand::DelimitReplacement(
  571. UnicodeString & /*Replacement*/, wchar_t /*Quote*/)
  572. {
  573. // never delimit local commands
  574. }
  575. //---------------------------------------------------------------------------
  576. bool __fastcall TLocalCustomCommand::HasLocalFileName(const UnicodeString & Command)
  577. {
  578. return FindPattern(Command, L'^');
  579. }
  580. //---------------------------------------------------------------------------
  581. bool __fastcall TLocalCustomCommand::IsFileCommand(const UnicodeString & Command)
  582. {
  583. return TFileCustomCommand::IsFileCommand(Command) || HasLocalFileName(Command);
  584. }