CopyParam.h 7.2 KB

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