CopyParam.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //---------------------------------------------------------------------------
  2. #ifndef CopyParamH
  3. #define CopyParamH
  4. #include "FileMasks.h"
  5. #include "RemoteFiles.h"
  6. //---------------------------------------------------------------------------
  7. // When adding new options, mind TCopyParamType::GetLogStr()
  8. enum TOperationSide { osLocal, osRemote, osCurrent };
  9. enum TFileNameCase { ncNoChange, ncUpperCase, ncLowerCase, ncFirstUpperCase, ncLowerCaseShort };
  10. // TScript::OptionProc depend on the order
  11. enum TTransferMode { tmBinary, tmAscii, tmAutomatic };
  12. enum TResumeSupport { rsOn, rsSmart, rsOff };
  13. class THierarchicalStorage;
  14. const int cpaExcludeMaskOnly = 0x01;
  15. const int cpaNoTransferMode = 0x02;
  16. const int cpaNoExcludeMask = 0x04;
  17. const int cpaNoClearArchive = 0x08;
  18. const int cpaNoPreserveTime = 0x10;
  19. const int cpaNoRights = 0x20;
  20. const int cpaNoPreserveReadOnly = 0x40;
  21. const int cpaNoIgnorePermErrors = 0x80;
  22. //---------------------------------------------------------------------------
  23. struct TUsableCopyParamAttrs
  24. {
  25. int General;
  26. int Upload;
  27. int Download;
  28. };
  29. //---------------------------------------------------------------------------
  30. class TCopyParamType {
  31. private:
  32. TFileMasks FAsciiFileMask;
  33. TFileNameCase FFileNameCase;
  34. bool FPreserveReadOnly;
  35. bool FPreserveTime;
  36. TRights FRights;
  37. TTransferMode FTransferMode;
  38. bool FAddXToDirectories;
  39. bool FPreserveRights;
  40. bool FIgnorePermErrors;
  41. TResumeSupport FResumeSupport;
  42. __int64 FResumeThreshold;
  43. AnsiString __fastcall GetLogStr() const;
  44. char FInvalidCharsReplacement;
  45. AnsiString FLocalInvalidChars;
  46. AnsiString FTokenizibleChars;
  47. bool FCalculateSize;
  48. AnsiString FFileMask;
  49. TFileMasks FExcludeFileMask;
  50. bool FNegativeExclude;
  51. bool FClearArchive;
  52. unsigned long FCPSLimit;
  53. static const char TokenPrefix = '%';
  54. static const char NoReplacement = char(false);
  55. static const char TokenReplacement = char(true);
  56. static AnsiString __fastcall Untokenize(AnsiString FileName);
  57. void __fastcall SetLocalInvalidChars(AnsiString value);
  58. bool __fastcall GetReplaceInvalidChars() const;
  59. void __fastcall SetReplaceInvalidChars(bool value);
  60. char * __fastcall ReplaceChar(AnsiString & FileName, char * InvalidChar) const;
  61. AnsiString __fastcall RestoreChars(AnsiString FileName) const;
  62. public:
  63. __fastcall TCopyParamType();
  64. __fastcall TCopyParamType(const TCopyParamType & Source);
  65. virtual __fastcall ~TCopyParamType();
  66. TCopyParamType & __fastcall operator =(const TCopyParamType & rhp);
  67. virtual void __fastcall Assign(const TCopyParamType * Source);
  68. virtual void __fastcall Default();
  69. AnsiString __fastcall ChangeFileName(AnsiString FileName,
  70. TOperationSide Side, bool FirstLevel) const;
  71. int __fastcall LocalFileAttrs(const TRights & Rights) const;
  72. TRights __fastcall RemoteFileRights(int Attrs) const;
  73. bool __fastcall UseAsciiTransfer(AnsiString FileName, TOperationSide Side,
  74. const TFileMasks::TParams & Params) const;
  75. bool __fastcall AllowResume(__int64 Size) const;
  76. AnsiString __fastcall ValidLocalFileName(AnsiString FileName) const;
  77. AnsiString __fastcall ValidLocalPath(AnsiString Path) const;
  78. bool __fastcall AllowTransfer(AnsiString FileName, TOperationSide Side,
  79. bool Directory, const TFileMasks::TParams & Params) const;
  80. void __fastcall Load(THierarchicalStorage * Storage);
  81. void __fastcall Save(THierarchicalStorage * Storage) const;
  82. AnsiString __fastcall GetInfoStr(AnsiString Separator, int Attrs) const;
  83. bool __fastcall operator==(const TCopyParamType & rhp) const;
  84. __property TFileMasks AsciiFileMask = { read = FAsciiFileMask, write = FAsciiFileMask };
  85. __property TFileNameCase FileNameCase = { read = FFileNameCase, write = FFileNameCase };
  86. __property bool PreserveReadOnly = { read = FPreserveReadOnly, write = FPreserveReadOnly };
  87. __property bool PreserveTime = { read = FPreserveTime, write = FPreserveTime };
  88. __property TRights Rights = { read = FRights, write = FRights };
  89. __property TTransferMode TransferMode = { read = FTransferMode, write = FTransferMode };
  90. __property AnsiString LogStr = { read=GetLogStr };
  91. __property bool AddXToDirectories = { read=FAddXToDirectories, write=FAddXToDirectories };
  92. __property bool PreserveRights = { read = FPreserveRights, write = FPreserveRights };
  93. __property bool IgnorePermErrors = { read = FIgnorePermErrors, write = FIgnorePermErrors };
  94. __property TResumeSupport ResumeSupport = { read = FResumeSupport, write = FResumeSupport };
  95. __property __int64 ResumeThreshold = { read = FResumeThreshold, write = FResumeThreshold };
  96. __property char InvalidCharsReplacement = { read = FInvalidCharsReplacement, write = FInvalidCharsReplacement };
  97. __property bool ReplaceInvalidChars = { read = GetReplaceInvalidChars, write = SetReplaceInvalidChars };
  98. __property AnsiString LocalInvalidChars = { read = FLocalInvalidChars, write = SetLocalInvalidChars };
  99. __property bool CalculateSize = { read = FCalculateSize, write = FCalculateSize };
  100. __property AnsiString FileMask = { read = FFileMask, write = FFileMask };
  101. __property TFileMasks ExcludeFileMask = { read = FExcludeFileMask, write = FExcludeFileMask };
  102. __property bool NegativeExclude = { read = FNegativeExclude, write = FNegativeExclude };
  103. __property bool ClearArchive = { read = FClearArchive, write = FClearArchive };
  104. __property unsigned long CPSLimit = { read = FCPSLimit, write = FCPSLimit };
  105. };
  106. //---------------------------------------------------------------------------
  107. #endif