FileOperationProgress.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //---------------------------------------------------------------------------
  2. #ifndef FileOperationProgressH
  3. #define FileOperationProgressH
  4. //---------------------------------------------------------------------------
  5. #include "Configuration.h"
  6. //---------------------------------------------------------------------------
  7. class TFileOperationProgressType;
  8. enum TFileOperation { foNone, foCopy, foMove, foDelete, foSetProperties,
  9. foRename, foCustomCommand };
  10. enum TCancelStatus { csContinue = 0, csCancel, csCancelTransfer, csRemoteAbort };
  11. enum TResumeStatus { rsNotAvailable, rsEnabled, rsDisabled };
  12. typedef void __fastcall (__closure *TFileOperationProgressEvent)
  13. (TFileOperationProgressType & ProgressData, TCancelStatus & Cancel);
  14. typedef void __fastcall (__closure *TFileOperationFinished)
  15. (TOperationSide Side, bool DragDrop, const AnsiString FileName,
  16. bool Success, bool & DisconnectWhenComplete);
  17. //---------------------------------------------------------------------------
  18. class TFileOperationProgressType
  19. {
  20. private:
  21. // how long it was stopped (e.g. while displaying error message)
  22. TDateTime FStopped;
  23. // when it was last time suspended (to calculate suspend time in Resume())
  24. TDateTime FSuspendTime;
  25. // when current file was started being transfered
  26. TDateTime FFileStartTime;
  27. // how long current file transfer was stopped (e.g. while displaying error message)
  28. TDateTime FFileStopped;
  29. int FFilesFinished;
  30. TFileOperationProgressEvent FOnProgress;
  31. TFileOperationFinished FOnFinished;
  32. protected:
  33. void __fastcall ClearTransfer();
  34. void __fastcall DoProgress();
  35. public:
  36. // common data
  37. TFileOperation Operation;
  38. // on what side if operation being processed (local/remote), source of copy
  39. TOperationSide Side;
  40. AnsiString FileName;
  41. AnsiString Directory;
  42. bool AsciiTransfer;
  43. bool TransferingFile;
  44. bool DragDrop;
  45. // file size to read/write
  46. __int64 LocalSize;
  47. __int64 LocalyUsed;
  48. __int64 TransferSize;
  49. __int64 TransferedSize;
  50. TResumeStatus ResumeStatus;
  51. bool InProgress;
  52. TCancelStatus Cancel;
  53. int Count;
  54. // when operation started
  55. TDateTime StartTime;
  56. // bytes transfered
  57. __int64 TotalTransfered;
  58. __int64 TotalResumed;
  59. bool YesToAll;
  60. bool NoToAll;
  61. bool Suspended;
  62. __fastcall TFileOperationProgressType(
  63. TFileOperationProgressEvent AOnProgress, TFileOperationFinished AOnFinished);
  64. __fastcall ~TFileOperationProgressType();
  65. //void __fastcall operator =(const TFileOperationProgressType & rht);
  66. void __fastcall AddLocalyUsed(__int64 ASize);
  67. void __fastcall AddTransfered(__int64 ASize);
  68. void __fastcall AddResumed(__int64 ASize);
  69. void __fastcall Clear();
  70. unsigned int __fastcall CPS();
  71. void __fastcall Finish(AnsiString FileName, bool Success,
  72. bool & DisconnectWhenComplete);
  73. unsigned long __fastcall LocalBlockSize();
  74. bool __fastcall IsLocalyDone();
  75. bool __fastcall IsTransferDone();
  76. void __fastcall SetFile(AnsiString AFileName);
  77. int __fastcall OperationProgress();
  78. unsigned long __fastcall TransferBlockSize();
  79. unsigned long __fastcall StaticBlockSize();
  80. void __fastcall Resume();
  81. void __fastcall SetLocalSize(__int64 ASize);
  82. void __fastcall SetAsciiTransfer(bool AAsciiTransfer);
  83. void __fastcall SetResumeStatus(TResumeStatus AResumeStatus);
  84. void __fastcall SetTransferSize(__int64 ASize);
  85. void __fastcall Start(TFileOperation AOperation,
  86. TOperationSide ASide, int ACount, bool ADragDrop = false,
  87. const AnsiString ADirectory = "");
  88. void __fastcall Stop();
  89. void __fastcall Suspend();
  90. __fastcall TFileOperationProgressType();
  91. // whole operation
  92. TDateTime __fastcall TimeElapsed();
  93. // only current file
  94. TDateTime __fastcall TimeExpected();
  95. int __fastcall TransferProgress();
  96. };
  97. //---------------------------------------------------------------------------
  98. #endif