Update.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // Update.h
  2. #ifndef __UPDATE_H
  3. #define __UPDATE_H
  4. #include "Common/Wildcard.h"
  5. #include "Windows/FileFind.h"
  6. #include "../../Archive/IArchive.h"
  7. #include "UpdateAction.h"
  8. #include "ArchiveOpenCallback.h"
  9. #include "UpdateCallback.h"
  10. #include "Property.h"
  11. #include "LoadCodecs.h"
  12. struct CArchivePath
  13. {
  14. UString Prefix; // path(folder) prefix including slash
  15. UString Name; // base name
  16. UString BaseExtension; // archive type extension or "exe" extension
  17. UString VolExtension; // archive type extension for volumes
  18. bool Temp;
  19. UString TempPrefix; // path(folder) for temp location
  20. UString TempPostfix;
  21. CArchivePath(): Temp(false) {};
  22. void ParseFromPath(const UString &path)
  23. {
  24. SplitPathToParts(path, Prefix, Name);
  25. if (Name.IsEmpty())
  26. return;
  27. int dotPos = Name.ReverseFind(L'.');
  28. if (dotPos <= 0)
  29. return;
  30. if (dotPos == Name.Length() - 1)
  31. {
  32. Name = Name.Left(dotPos);
  33. BaseExtension.Empty();
  34. return;
  35. }
  36. if (BaseExtension.CompareNoCase(Name.Mid(dotPos + 1)) == 0)
  37. {
  38. BaseExtension = Name.Mid(dotPos + 1);
  39. Name = Name.Left(dotPos);
  40. }
  41. else
  42. BaseExtension.Empty();
  43. }
  44. UString GetPathWithoutExt() const
  45. {
  46. return Prefix + Name;
  47. }
  48. UString GetFinalPath() const
  49. {
  50. UString path = GetPathWithoutExt();
  51. if (!BaseExtension.IsEmpty())
  52. path += UString(L'.') + BaseExtension;
  53. return path;
  54. }
  55. UString GetTempPath() const
  56. {
  57. UString path = TempPrefix + Name;
  58. if (!BaseExtension.IsEmpty())
  59. path += UString(L'.') + BaseExtension;
  60. path += L".tmp";
  61. path += TempPostfix;
  62. return path;
  63. }
  64. };
  65. struct CUpdateArchiveCommand
  66. {
  67. UString UserArchivePath;
  68. CArchivePath ArchivePath;
  69. NUpdateArchive::CActionSet ActionSet;
  70. };
  71. struct CCompressionMethodMode
  72. {
  73. int FormatIndex;
  74. CObjectVector<CProperty> Properties;
  75. CCompressionMethodMode(): FormatIndex(-1) {}
  76. };
  77. struct CUpdateOptions
  78. {
  79. CCompressionMethodMode MethodMode;
  80. CObjectVector<CUpdateArchiveCommand> Commands;
  81. bool UpdateArchiveItself;
  82. CArchivePath ArchivePath;
  83. bool SfxMode;
  84. UString SfxModule;
  85. bool OpenShareForWrite;
  86. bool StdInMode;
  87. UString StdInFileName;
  88. bool StdOutMode;
  89. bool EMailMode;
  90. bool EMailRemoveAfter;
  91. UString EMailAddress;
  92. UString WorkingDir;
  93. bool Init(const CCodecs *codecs, const UString &arcPath, const UString &arcType);
  94. CUpdateOptions():
  95. UpdateArchiveItself(true),
  96. SfxMode(false),
  97. StdInMode(false),
  98. StdOutMode(false),
  99. EMailMode(false),
  100. EMailRemoveAfter(false),
  101. OpenShareForWrite(false)
  102. {};
  103. CRecordVector<UInt64> VolumesSizes;
  104. };
  105. struct CErrorInfo
  106. {
  107. DWORD SystemError;
  108. UString FileName;
  109. UString FileName2;
  110. UString Message;
  111. // UStringVector ErrorPaths;
  112. // CRecordVector<DWORD> ErrorCodes;
  113. CErrorInfo(): SystemError(0) {};
  114. };
  115. struct CUpdateErrorInfo: public CErrorInfo
  116. {
  117. };
  118. #define INTERFACE_IUpdateCallbackUI2(x) \
  119. INTERFACE_IUpdateCallbackUI(x) \
  120. virtual HRESULT OpenResult(const wchar_t *name, HRESULT result) x; \
  121. virtual HRESULT StartScanning() x; \
  122. virtual HRESULT CanNotFindError(const wchar_t *name, DWORD systemError) x; \
  123. virtual HRESULT FinishScanning() x; \
  124. virtual HRESULT StartArchive(const wchar_t *name, bool updating) x; \
  125. virtual HRESULT FinishArchive() x; \
  126. struct IUpdateCallbackUI2: public IUpdateCallbackUI
  127. {
  128. INTERFACE_IUpdateCallbackUI2(=0)
  129. };
  130. HRESULT UpdateArchive(
  131. CCodecs *codecs,
  132. const NWildcard::CCensor &censor,
  133. CUpdateOptions &options,
  134. CUpdateErrorInfo &errorInfo,
  135. IOpenCallbackUI *openCallback,
  136. IUpdateCallbackUI2 *callback);
  137. #endif