FileSystems.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "FileSystems.h"
  5. #include "RemoteFiles.h"
  6. #include "Common.h"
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9. //---------------------------------------------------------------------------
  10. __fastcall TCustomFileSystem::TCustomFileSystem(TTerminal * ATerminal):
  11. TObject(), FTerminal(ATerminal)
  12. {
  13. assert(FTerminal);
  14. }
  15. //---------------------------------------------------------------------------
  16. AnsiString __fastcall TCustomFileSystem::CompleteCustomCommand(AnsiString Command,
  17. const AnsiString FileName, TGetParamValueEvent OnGetParamValue)
  18. {
  19. char * Ptr = Command.c_str();
  20. do
  21. {
  22. Ptr = strchr(Ptr, '!');
  23. if (Ptr)
  24. {
  25. int P = Ptr - Command.c_str() + 1;
  26. if (*(Ptr+1) == '!')
  27. {
  28. Command.Delete(P, 1);
  29. }
  30. /*else if (*(Ptr+1) == '/')
  31. {
  32. if (File)
  33. {
  34. Command.Delete(P, 2);
  35. Command.Insert(File->Directory->FullDirectory, P);
  36. P += File->Directory->FullDirectory.Length() - 1;
  37. }
  38. } */
  39. else if (*(Ptr+1) == '?')
  40. {
  41. char * Ptr2 = strchr(Ptr + 2, '?');
  42. char * Ptr3 = strchr(Ptr + 1, '!');
  43. if (Ptr2 && Ptr3 && Ptr2 < Ptr3)
  44. {
  45. if (OnGetParamValue)
  46. {
  47. AnsiString Title(Ptr + 2, Ptr2 - Ptr - 2);
  48. AnsiString Value(Ptr2 + 1, Ptr3 - Ptr2 - 1);
  49. OnGetParamValue(Title, Value);
  50. Command.Delete(P, Ptr3 - Ptr + 1);
  51. Command.Insert(Value, P);
  52. P += Value.Length() - 1;
  53. }
  54. else
  55. {
  56. P += Ptr3 - Ptr;
  57. }
  58. }
  59. else
  60. {
  61. P++;
  62. }
  63. }
  64. else
  65. {
  66. if (!FileName.IsEmpty())
  67. {
  68. Command.Delete(P, 1);
  69. Command.Insert(FileName, P);
  70. P += FileName.Length() - 1;
  71. }
  72. }
  73. Ptr = Command.c_str() + P;
  74. }
  75. }
  76. while (Ptr);
  77. return Command;
  78. }