CopyParam.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 cpaIncludeMaskOnly = 0x01;
  15. const int cpaNoTransferMode = 0x02;
  16. const int cpaNoIncludeMask = 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. const int cpaNoNewerOnly = 0x100;
  23. const int cpaNoRemoveCtrlZ = 0x200;
  24. const int cpaNoRemoveBOM = 0x400;
  25. const int cpaNoPreserveTimeDirs = 0x800;
  26. //---------------------------------------------------------------------------
  27. struct TUsableCopyParamAttrs
  28. {
  29. int General;
  30. int Upload;
  31. int Download;
  32. };
  33. //---------------------------------------------------------------------------
  34. class TCopyParamType
  35. {
  36. private:
  37. TFileMasks FAsciiFileMask;
  38. TFileNameCase FFileNameCase;
  39. bool FPreserveReadOnly;
  40. bool FPreserveTime;
  41. bool FPreserveTimeDirs;
  42. TRights FRights;
  43. TTransferMode FTransferMode;
  44. bool FAddXToDirectories;
  45. bool FPreserveRights;
  46. bool FIgnorePermErrors;
  47. TResumeSupport FResumeSupport;
  48. __int64 FResumeThreshold;
  49. UnicodeString __fastcall GetLogStr() const;
  50. wchar_t FInvalidCharsReplacement;
  51. UnicodeString FLocalInvalidChars;
  52. UnicodeString FTokenizibleChars;
  53. bool FCalculateSize;
  54. UnicodeString FFileMask;
  55. TFileMasks FIncludeFileMask;
  56. std::unique_ptr<TStringList> FTransferSkipList;
  57. UnicodeString FTransferResumeFile;
  58. bool FClearArchive;
  59. bool FRemoveCtrlZ;
  60. bool FRemoveBOM;
  61. unsigned long FCPSLimit;
  62. bool FNewerOnly;
  63. static const wchar_t TokenPrefix = L'%';
  64. static const wchar_t NoReplacement = wchar_t(false);
  65. static const wchar_t TokenReplacement = wchar_t(true);
  66. void __fastcall SetLocalInvalidChars(UnicodeString value);
  67. bool __fastcall GetReplaceInvalidChars() const;
  68. void __fastcall SetReplaceInvalidChars(bool value);
  69. UnicodeString __fastcall RestoreChars(UnicodeString FileName) const;
  70. void __fastcall DoGetInfoStr(UnicodeString Separator, int Attrs,
  71. UnicodeString & Result, bool & SomeAttrIncluded) const;
  72. TStrings * __fastcall GetTransferSkipList() const;
  73. void __fastcall SetTransferSkipList(TStrings * value);
  74. public:
  75. __fastcall TCopyParamType();
  76. __fastcall TCopyParamType(const TCopyParamType & Source);
  77. virtual __fastcall ~TCopyParamType();
  78. TCopyParamType & __fastcall operator =(const TCopyParamType & rhp);
  79. virtual void __fastcall Assign(const TCopyParamType * Source);
  80. virtual void __fastcall Default();
  81. UnicodeString __fastcall ChangeFileName(UnicodeString FileName,
  82. TOperationSide Side, bool FirstLevel) const;
  83. int __fastcall LocalFileAttrs(const TRights & Rights) const;
  84. TRights __fastcall RemoteFileRights(int Attrs) const;
  85. bool __fastcall UseAsciiTransfer(UnicodeString FileName, TOperationSide Side,
  86. const TFileMasks::TParams & Params) const;
  87. bool __fastcall AllowResume(__int64 Size) const;
  88. bool __fastcall ResumeTransfer(UnicodeString FileName) const;
  89. UnicodeString __fastcall ValidLocalFileName(UnicodeString FileName) const;
  90. UnicodeString __fastcall ValidLocalPath(UnicodeString Path) const;
  91. bool __fastcall AllowAnyTransfer() const;
  92. bool __fastcall AllowTransfer(UnicodeString FileName, TOperationSide Side,
  93. bool Directory, const TFileMasks::TParams & Params) const;
  94. bool __fastcall SkipTransfer(UnicodeString FileName, bool Directory) const;
  95. void __fastcall Load(THierarchicalStorage * Storage);
  96. void __fastcall Save(THierarchicalStorage * Storage) const;
  97. UnicodeString __fastcall GetInfoStr(UnicodeString Separator, int Attrs) const;
  98. bool __fastcall AnyUsableCopyParam(int Attrs) const;
  99. bool __fastcall operator==(const TCopyParamType & rhp) const;
  100. __property TFileMasks AsciiFileMask = { read = FAsciiFileMask, write = FAsciiFileMask };
  101. __property TFileNameCase FileNameCase = { read = FFileNameCase, write = FFileNameCase };
  102. __property bool PreserveReadOnly = { read = FPreserveReadOnly, write = FPreserveReadOnly };
  103. __property bool PreserveTime = { read = FPreserveTime, write = FPreserveTime };
  104. __property bool PreserveTimeDirs = { read = FPreserveTimeDirs, write = FPreserveTimeDirs };
  105. __property TRights Rights = { read = FRights, write = FRights };
  106. __property TTransferMode TransferMode = { read = FTransferMode, write = FTransferMode };
  107. __property UnicodeString LogStr = { read=GetLogStr };
  108. __property bool AddXToDirectories = { read=FAddXToDirectories, write=FAddXToDirectories };
  109. __property bool PreserveRights = { read = FPreserveRights, write = FPreserveRights };
  110. __property bool IgnorePermErrors = { read = FIgnorePermErrors, write = FIgnorePermErrors };
  111. __property TResumeSupport ResumeSupport = { read = FResumeSupport, write = FResumeSupport };
  112. __property __int64 ResumeThreshold = { read = FResumeThreshold, write = FResumeThreshold };
  113. __property wchar_t InvalidCharsReplacement = { read = FInvalidCharsReplacement, write = FInvalidCharsReplacement };
  114. __property bool ReplaceInvalidChars = { read = GetReplaceInvalidChars, write = SetReplaceInvalidChars };
  115. __property UnicodeString LocalInvalidChars = { read = FLocalInvalidChars, write = SetLocalInvalidChars };
  116. __property bool CalculateSize = { read = FCalculateSize, write = FCalculateSize };
  117. __property UnicodeString FileMask = { read = FFileMask, write = FFileMask };
  118. __property TFileMasks IncludeFileMask = { read = FIncludeFileMask, write = FIncludeFileMask };
  119. __property TStrings * TransferSkipList = { read = GetTransferSkipList, write = SetTransferSkipList };
  120. __property UnicodeString TransferResumeFile = { read = FTransferResumeFile, write = FTransferResumeFile };
  121. __property bool ClearArchive = { read = FClearArchive, write = FClearArchive };
  122. __property bool RemoveCtrlZ = { read = FRemoveCtrlZ, write = FRemoveCtrlZ };
  123. __property bool RemoveBOM = { read = FRemoveBOM, write = FRemoveBOM };
  124. __property unsigned long CPSLimit = { read = FCPSLimit, write = FCPSLimit };
  125. __property bool NewerOnly = { read = FNewerOnly, write = FNewerOnly };
  126. };
  127. //---------------------------------------------------------------------------
  128. unsigned long __fastcall GetSpeedLimit(const UnicodeString & Text);
  129. UnicodeString __fastcall SetSpeedLimit(unsigned long Limit);
  130. void __fastcall CopySpeedLimits(TStrings * Source, TStrings * Dest);
  131. //---------------------------------------------------------------------------
  132. #endif