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