CopyParam.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. bool FClearArchive;
  55. bool FRemoveCtrlZ;
  56. bool FRemoveBOM;
  57. unsigned long FCPSLimit;
  58. bool FNewerOnly;
  59. static const wchar_t TokenPrefix = L'%';
  60. static const wchar_t NoReplacement = wchar_t(false);
  61. static const wchar_t TokenReplacement = wchar_t(true);
  62. void __fastcall SetLocalInvalidChars(UnicodeString value);
  63. bool __fastcall GetReplaceInvalidChars() const;
  64. void __fastcall SetReplaceInvalidChars(bool value);
  65. UnicodeString __fastcall RestoreChars(UnicodeString FileName) const;
  66. void __fastcall DoGetInfoStr(UnicodeString Separator, int Attrs,
  67. UnicodeString & Result, bool & SomeAttrIncluded) const;
  68. public:
  69. __fastcall TCopyParamType();
  70. __fastcall TCopyParamType(const TCopyParamType & Source);
  71. virtual __fastcall ~TCopyParamType();
  72. TCopyParamType & __fastcall operator =(const TCopyParamType & rhp);
  73. virtual void __fastcall Assign(const TCopyParamType * Source);
  74. virtual void __fastcall Default();
  75. UnicodeString __fastcall ChangeFileName(UnicodeString FileName,
  76. TOperationSide Side, bool FirstLevel) const;
  77. int __fastcall LocalFileAttrs(const TRights & Rights) const;
  78. TRights __fastcall RemoteFileRights(int Attrs) const;
  79. bool __fastcall UseAsciiTransfer(UnicodeString FileName, TOperationSide Side,
  80. const TFileMasks::TParams & Params) const;
  81. bool __fastcall AllowResume(__int64 Size) const;
  82. UnicodeString __fastcall ValidLocalFileName(UnicodeString FileName) const;
  83. UnicodeString __fastcall ValidLocalPath(UnicodeString Path) const;
  84. bool __fastcall AllowAnyTransfer() const;
  85. bool __fastcall AllowTransfer(UnicodeString FileName, TOperationSide Side,
  86. bool Directory, const TFileMasks::TParams & Params) const;
  87. void __fastcall Load(THierarchicalStorage * Storage);
  88. void __fastcall Save(THierarchicalStorage * Storage) const;
  89. UnicodeString __fastcall GetInfoStr(UnicodeString Separator, int Attrs) const;
  90. bool __fastcall AnyUsableCopyParam(int Attrs) const;
  91. bool __fastcall operator==(const TCopyParamType & rhp) const;
  92. __property TFileMasks AsciiFileMask = { read = FAsciiFileMask, write = FAsciiFileMask };
  93. __property TFileNameCase FileNameCase = { read = FFileNameCase, write = FFileNameCase };
  94. __property bool PreserveReadOnly = { read = FPreserveReadOnly, write = FPreserveReadOnly };
  95. __property bool PreserveTime = { read = FPreserveTime, write = FPreserveTime };
  96. __property TRights Rights = { read = FRights, write = FRights };
  97. __property TTransferMode TransferMode = { read = FTransferMode, write = FTransferMode };
  98. __property UnicodeString LogStr = { read=GetLogStr };
  99. __property bool AddXToDirectories = { read=FAddXToDirectories, write=FAddXToDirectories };
  100. __property bool PreserveRights = { read = FPreserveRights, write = FPreserveRights };
  101. __property bool IgnorePermErrors = { read = FIgnorePermErrors, write = FIgnorePermErrors };
  102. __property TResumeSupport ResumeSupport = { read = FResumeSupport, write = FResumeSupport };
  103. __property __int64 ResumeThreshold = { read = FResumeThreshold, write = FResumeThreshold };
  104. __property wchar_t InvalidCharsReplacement = { read = FInvalidCharsReplacement, write = FInvalidCharsReplacement };
  105. __property bool ReplaceInvalidChars = { read = GetReplaceInvalidChars, write = SetReplaceInvalidChars };
  106. __property UnicodeString LocalInvalidChars = { read = FLocalInvalidChars, write = SetLocalInvalidChars };
  107. __property bool CalculateSize = { read = FCalculateSize, write = FCalculateSize };
  108. __property UnicodeString FileMask = { read = FFileMask, write = FFileMask };
  109. __property TFileMasks IncludeFileMask = { read = FIncludeFileMask, write = FIncludeFileMask };
  110. __property bool ClearArchive = { read = FClearArchive, write = FClearArchive };
  111. __property bool RemoveCtrlZ = { read = FRemoveCtrlZ, write = FRemoveCtrlZ };
  112. __property bool RemoveBOM = { read = FRemoveBOM, write = FRemoveBOM };
  113. __property unsigned long CPSLimit = { read = FCPSLimit, write = FCPSLimit };
  114. __property bool NewerOnly = { read = FNewerOnly, write = FNewerOnly };
  115. };
  116. //---------------------------------------------------------------------------
  117. unsigned long __fastcall GetSpeedLimit(const UnicodeString & Text);
  118. UnicodeString __fastcall SetSpeedLimit(unsigned long Limit);
  119. //---------------------------------------------------------------------------
  120. #endif