CopyParam.h 7.9 KB

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