CopyParam.h 6.7 KB

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