CopyParam.h 8.5 KB

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