1 // Update.h 2 3 #ifndef __COMMON_UPDATE_H 4 #define __COMMON_UPDATE_H 5 6 #include "../../../Common/Wildcard.h" 7 8 #include "ArchiveOpenCallback.h" 9 #include "LoadCodecs.h" 10 #include "OpenArchive.h" 11 #include "Property.h" 12 #include "UpdateAction.h" 13 #include "UpdateCallback.h" 14 15 enum EArcNameMode 16 { 17 k_ArcNameMode_Smart, 18 k_ArcNameMode_Exact, 19 k_ArcNameMode_Add, 20 }; 21 22 struct CArchivePath 23 { 24 UString OriginalPath; 25 26 UString Prefix; // path(folder) prefix including slash 27 UString Name; // base name 28 UString BaseExtension; // archive type extension or "exe" extension 29 UString VolExtension; // archive type extension for volumes 30 31 bool Temp; 32 FString TempPrefix; // path(folder) for temp location 33 FString TempPostfix; 34 CArchivePathCArchivePath35 CArchivePath(): Temp(false) {}; 36 37 void ParseFromPath(const UString &path, EArcNameMode mode); GetPathWithoutExtCArchivePath38 UString GetPathWithoutExt() const { return Prefix + Name; } 39 UString GetFinalPath() const; 40 UString GetFinalVolPath() const; 41 FString GetTempPath() const; 42 }; 43 44 struct CUpdateArchiveCommand 45 { 46 UString UserArchivePath; 47 CArchivePath ArchivePath; 48 NUpdateArchive::CActionSet ActionSet; 49 }; 50 51 struct CCompressionMethodMode 52 { 53 bool Type_Defined; 54 COpenType Type; 55 CObjectVector<CProperty> Properties; 56 CCompressionMethodModeCCompressionMethodMode57 CCompressionMethodMode(): Type_Defined(false) {} 58 }; 59 60 namespace NRecursedType { enum EEnum 61 { 62 kRecursed, 63 kWildcardOnlyRecursed, 64 kNonRecursed 65 };} 66 67 struct CRenamePair 68 { 69 UString OldName; 70 UString NewName; 71 bool WildcardParsing; 72 NRecursedType::EEnum RecursedType; 73 CRenamePairCRenamePair74 CRenamePair(): WildcardParsing(true), RecursedType(NRecursedType::kNonRecursed) {} 75 76 bool Prepare(); 77 bool GetNewPath(bool isFolder, const UString &src, UString &dest) const; 78 }; 79 80 struct CUpdateOptions 81 { 82 CCompressionMethodMode MethodMode; 83 84 CObjectVector<CUpdateArchiveCommand> Commands; 85 bool UpdateArchiveItself; 86 CArchivePath ArchivePath; 87 EArcNameMode ArcNameMode; 88 89 bool SfxMode; 90 FString SfxModule; 91 92 bool OpenShareForWrite; 93 94 bool StdInMode; 95 UString StdInFileName; 96 bool StdOutMode; 97 98 bool EMailMode; 99 bool EMailRemoveAfter; 100 UString EMailAddress; 101 102 FString WorkingDir; 103 NWildcard::ECensorPathMode PathMode; 104 UString AddPathPrefix; 105 106 CBoolPair NtSecurity; 107 CBoolPair AltStreams; 108 CBoolPair HardLinks; 109 CBoolPair SymLinks; 110 111 bool DeleteAfterCompressing; 112 113 bool SetArcMTime; 114 115 CObjectVector<CRenamePair> RenamePairs; 116 117 bool InitFormatIndex(const CCodecs *codecs, const CObjectVector<COpenType> &types, const UString &arcPath); 118 bool SetArcPath(const CCodecs *codecs, const UString &arcPath); 119 CUpdateOptionsCUpdateOptions120 CUpdateOptions(): 121 UpdateArchiveItself(true), 122 SfxMode(false), 123 StdInMode(false), 124 StdOutMode(false), 125 EMailMode(false), 126 EMailRemoveAfter(false), 127 OpenShareForWrite(false), 128 ArcNameMode(k_ArcNameMode_Smart), 129 PathMode(NWildcard::k_RelatPath), 130 131 DeleteAfterCompressing(false), 132 SetArcMTime(false) 133 134 {}; 135 SetActionCommand_AddCUpdateOptions136 void SetActionCommand_Add() 137 { 138 Commands.Clear(); 139 CUpdateArchiveCommand c; 140 c.ActionSet = NUpdateArchive::k_ActionSet_Add; 141 Commands.Add(c); 142 } 143 144 CRecordVector<UInt64> VolumesSizes; 145 }; 146 147 struct CErrorInfo 148 { 149 DWORD SystemError; 150 FString FileName; 151 FString FileName2; 152 UString Message; 153 // UStringVector ErrorPaths; 154 // CRecordVector<DWORD> ErrorCodes; CErrorInfoCErrorInfo155 CErrorInfo(): SystemError(0) {}; 156 }; 157 158 struct CUpdateErrorInfo: public CErrorInfo 159 { 160 }; 161 162 #define INTERFACE_IUpdateCallbackUI2(x) \ 163 INTERFACE_IUpdateCallbackUI(x) \ 164 virtual HRESULT OpenResult(const wchar_t *name, HRESULT result, const wchar_t *errorArcType) x; \ 165 virtual HRESULT StartScanning() x; \ 166 virtual HRESULT ScanProgress(UInt64 numFolders, UInt64 numFiles, UInt64 totalSize, const wchar_t *path, bool isDir) x; \ 167 virtual HRESULT CanNotFindError(const wchar_t *name, DWORD systemError) x; \ 168 virtual HRESULT FinishScanning() x; \ 169 virtual HRESULT StartArchive(const wchar_t *name, bool updating) x; \ 170 virtual HRESULT FinishArchive() x; \ 171 172 struct IUpdateCallbackUI2: public IUpdateCallbackUI 173 { 174 INTERFACE_IUpdateCallbackUI2(=0) 175 }; 176 177 HRESULT UpdateArchive( 178 CCodecs *codecs, 179 const CObjectVector<COpenType> &types, 180 const UString &cmdArcPath2, 181 NWildcard::CCensor &censor, 182 CUpdateOptions &options, 183 CUpdateErrorInfo &errorInfo, 184 IOpenCallbackUI *openCallback, 185 IUpdateCallbackUI2 *callback, 186 bool needSetPath); 187 188 #endif 189