CopyParam.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //---------------------------------------------------------------------------
  2. #ifndef CopyParamH
  3. #define CopyParamH
  4. #include "FileMasks.h"
  5. #include "RemoteFiles.h"
  6. #include "Exceptions.h"
  7. //---------------------------------------------------------------------------
  8. // When adding new options, mind TCopyParamType::GetLogStr()
  9. enum TOperationSide { osLocal, osRemote, osCurrent };
  10. enum TFileNameCase { ncNoChange, ncUpperCase, ncLowerCase, ncFirstUpperCase, ncLowerCaseShort };
  11. // TScript::OptionProc depend on the order
  12. enum TTransferMode { tmBinary, tmAscii, tmAutomatic };
  13. enum TResumeSupport { rsOn, rsSmart, rsOff };
  14. class THierarchicalStorage;
  15. const int cpaIncludeMaskOnly = 0x01;
  16. const int cpaNoTransferMode = 0x02;
  17. const int cpaNoIncludeMask = 0x04;
  18. const int cpaNoClearArchive = 0x08;
  19. const int cpaNoPreserveTime = 0x10;
  20. const int cpaNoRights = 0x20;
  21. const int cpaNoPreserveReadOnly = 0x40;
  22. const int cpaNoIgnorePermErrors = 0x80;
  23. const int cpaNoNewerOnly = 0x100;
  24. const int cpaNoRemoveCtrlZ = 0x200;
  25. const int cpaNoRemoveBOM = 0x400;
  26. const int cpaNoPreserveTimeDirs = 0x800;
  27. const int cpaNoResumeSupport = 0x1000;
  28. const int cpaNoEncryptNewFiles = 0x2000;
  29. const int cpaNoCalculateSize = 0x4000;
  30. //---------------------------------------------------------------------------
  31. struct TUsableCopyParamAttrs
  32. {
  33. int General;
  34. int Upload;
  35. int Download;
  36. };
  37. //---------------------------------------------------------------------------
  38. class TCopyParamType
  39. {
  40. private:
  41. TFileMasks FAsciiFileMask;
  42. TFileNameCase FFileNameCase;
  43. bool FPreserveReadOnly;
  44. bool FPreserveTime;
  45. bool FPreserveTimeDirs;
  46. TRights FRights;
  47. TTransferMode FTransferMode;
  48. bool FAddXToDirectories;
  49. bool FPreserveRights;
  50. bool FIgnorePermErrors;
  51. TResumeSupport FResumeSupport;
  52. __int64 FResumeThreshold;
  53. UnicodeString __fastcall GetLogStr() const;
  54. wchar_t FInvalidCharsReplacement;
  55. UnicodeString FLocalInvalidChars;
  56. UnicodeString FTokenizibleChars;
  57. bool FCalculateSize;
  58. UnicodeString FFileMask;
  59. TFileMasks FIncludeFileMask;
  60. std::unique_ptr<TStringList> FTransferSkipList;
  61. UnicodeString FTransferResumeFile;
  62. bool FClearArchive;
  63. bool FRemoveCtrlZ;
  64. bool FRemoveBOM;
  65. unsigned long FCPSLimit;
  66. bool FNewerOnly;
  67. bool FEncryptNewFiles;
  68. bool FExcludeHiddenFiles;
  69. bool FExcludeEmptyDirectories;
  70. __int64 FSize;
  71. TOnceDoneOperation FOnceDoneOperation;
  72. static const wchar_t TokenPrefix = L'%';
  73. static const wchar_t NoReplacement = wchar_t(false);
  74. static const wchar_t TokenReplacement = wchar_t(true);
  75. void __fastcall SetLocalInvalidChars(UnicodeString value);
  76. bool __fastcall GetReplaceInvalidChars() const;
  77. void __fastcall SetReplaceInvalidChars(bool value);
  78. UnicodeString __fastcall RestoreChars(UnicodeString FileName) const;
  79. void __fastcall DoGetInfoStr(UnicodeString Separator, int Attrs,
  80. UnicodeString & Result, bool & SomeAttrIncluded, const UnicodeString & Link, UnicodeString & ScriptArgs,
  81. TAssemblyLanguage Language, UnicodeString & AssemblyCode) const;
  82. TStrings * __fastcall GetTransferSkipList() const;
  83. void __fastcall SetTransferSkipList(TStrings * value);
  84. public:
  85. __fastcall TCopyParamType();
  86. __fastcall TCopyParamType(const TCopyParamType & Source);
  87. virtual __fastcall ~TCopyParamType();
  88. TCopyParamType & __fastcall operator =(const TCopyParamType & rhp);
  89. virtual void __fastcall Assign(const TCopyParamType * Source);
  90. virtual void __fastcall Default();
  91. UnicodeString __fastcall ChangeFileName(UnicodeString FileName,
  92. TOperationSide Side, bool FirstLevel) const;
  93. int __fastcall LocalFileAttrs(const TRights & Rights) const;
  94. TRights __fastcall RemoteFileRights(int Attrs) const;
  95. bool __fastcall UseAsciiTransfer(UnicodeString FileName, TOperationSide Side,
  96. const TFileMasks::TParams & Params) const;
  97. bool __fastcall AllowResume(__int64 Size) const;
  98. bool __fastcall ResumeTransfer(UnicodeString FileName) const;
  99. UnicodeString __fastcall ValidLocalFileName(UnicodeString FileName) const;
  100. UnicodeString __fastcall ValidLocalPath(UnicodeString Path) const;
  101. bool __fastcall AllowAnyTransfer() const;
  102. bool __fastcall AllowTransfer(UnicodeString FileName, TOperationSide Side,
  103. bool Directory, const TFileMasks::TParams & Params, bool Hidden) const;
  104. bool __fastcall SkipTransfer(UnicodeString FileName, bool Directory) const;
  105. virtual void __fastcall Load(THierarchicalStorage * Storage);
  106. virtual void __fastcall Save(THierarchicalStorage * Storage, const TCopyParamType * Defaults = NULL) const;
  107. UnicodeString __fastcall GetInfoStr(UnicodeString Separator, int Attrs) const;
  108. bool __fastcall AnyUsableCopyParam(int Attrs) const;
  109. UnicodeString __fastcall GenerateTransferCommandArgs(int Attrs, const UnicodeString & Link) const;
  110. UnicodeString __fastcall GenerateAssemblyCode(TAssemblyLanguage Language, int Attrs) const;
  111. bool __fastcall operator==(const TCopyParamType & rhp) const;
  112. __property TFileMasks AsciiFileMask = { read = FAsciiFileMask, write = FAsciiFileMask };
  113. __property TFileNameCase FileNameCase = { read = FFileNameCase, write = FFileNameCase };
  114. __property bool PreserveReadOnly = { read = FPreserveReadOnly, write = FPreserveReadOnly };
  115. __property bool PreserveTime = { read = FPreserveTime, write = FPreserveTime };
  116. __property bool PreserveTimeDirs = { read = FPreserveTimeDirs, write = FPreserveTimeDirs };
  117. __property TRights Rights = { read = FRights, write = FRights };
  118. __property TTransferMode TransferMode = { read = FTransferMode, write = FTransferMode };
  119. __property UnicodeString LogStr = { read=GetLogStr };
  120. __property bool AddXToDirectories = { read=FAddXToDirectories, write=FAddXToDirectories };
  121. __property bool PreserveRights = { read = FPreserveRights, write = FPreserveRights };
  122. __property bool IgnorePermErrors = { read = FIgnorePermErrors, write = FIgnorePermErrors };
  123. __property TResumeSupport ResumeSupport = { read = FResumeSupport, write = FResumeSupport };
  124. __property __int64 ResumeThreshold = { read = FResumeThreshold, write = FResumeThreshold };
  125. __property wchar_t InvalidCharsReplacement = { read = FInvalidCharsReplacement, write = FInvalidCharsReplacement };
  126. __property bool ReplaceInvalidChars = { read = GetReplaceInvalidChars, write = SetReplaceInvalidChars };
  127. __property UnicodeString LocalInvalidChars = { read = FLocalInvalidChars, write = SetLocalInvalidChars };
  128. __property bool CalculateSize = { read = FCalculateSize, write = FCalculateSize };
  129. __property UnicodeString FileMask = { read = FFileMask, write = FFileMask };
  130. __property TFileMasks IncludeFileMask = { read = FIncludeFileMask, write = FIncludeFileMask };
  131. __property TStrings * TransferSkipList = { read = GetTransferSkipList, write = SetTransferSkipList };
  132. __property UnicodeString TransferResumeFile = { read = FTransferResumeFile, write = FTransferResumeFile };
  133. __property bool ClearArchive = { read = FClearArchive, write = FClearArchive };
  134. __property bool RemoveCtrlZ = { read = FRemoveCtrlZ, write = FRemoveCtrlZ };
  135. __property bool RemoveBOM = { read = FRemoveBOM, write = FRemoveBOM };
  136. __property unsigned long CPSLimit = { read = FCPSLimit, write = FCPSLimit };
  137. __property bool NewerOnly = { read = FNewerOnly, write = FNewerOnly };
  138. __property bool EncryptNewFiles = { read = FEncryptNewFiles, write = FEncryptNewFiles };
  139. __property bool ExcludeHiddenFiles = { read = FExcludeHiddenFiles, write = FExcludeHiddenFiles };
  140. __property bool ExcludeEmptyDirectories = { read = FExcludeEmptyDirectories, write = FExcludeEmptyDirectories };
  141. __property __int64 Size = { read = FSize, write = FSize };
  142. __property TOnceDoneOperation OnceDoneOperation = { read = FOnceDoneOperation, write = FOnceDoneOperation };
  143. };
  144. //---------------------------------------------------------------------------
  145. unsigned long __fastcall GetSpeedLimit(const UnicodeString & Text);
  146. UnicodeString __fastcall SetSpeedLimit(unsigned long Limit);
  147. void __fastcall CopySpeedLimits(TStrings * Source, TStrings * Dest);
  148. TOperationSide ReverseOperationSide(TOperationSide Side);
  149. //---------------------------------------------------------------------------
  150. #endif