Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | // 7z/Handler.h |
michael@0 | 2 | |
michael@0 | 3 | #ifndef __7Z_HANDLER_H |
michael@0 | 4 | #define __7Z_HANDLER_H |
michael@0 | 5 | |
michael@0 | 6 | #include "../IArchive.h" |
michael@0 | 7 | #include "7zIn.h" |
michael@0 | 8 | |
michael@0 | 9 | #include "7zCompressionMode.h" |
michael@0 | 10 | |
michael@0 | 11 | #ifndef _SFX |
michael@0 | 12 | #include "7zMethods.h" |
michael@0 | 13 | #endif |
michael@0 | 14 | |
michael@0 | 15 | #ifdef COMPRESS_MT |
michael@0 | 16 | #include "../../../Windows/System.h" |
michael@0 | 17 | #endif |
michael@0 | 18 | |
michael@0 | 19 | namespace NArchive { |
michael@0 | 20 | namespace N7z { |
michael@0 | 21 | |
michael@0 | 22 | #ifdef _7Z_VOL |
michael@0 | 23 | struct CRef |
michael@0 | 24 | { |
michael@0 | 25 | int VolumeIndex; |
michael@0 | 26 | int ItemIndex; |
michael@0 | 27 | }; |
michael@0 | 28 | |
michael@0 | 29 | /* |
michael@0 | 30 | struct CRef2 |
michael@0 | 31 | { |
michael@0 | 32 | CRecordVector<CRef> Refs; |
michael@0 | 33 | UInt64 UnPackSize; |
michael@0 | 34 | UInt64 PackSize; |
michael@0 | 35 | UInt64 StartPos; |
michael@0 | 36 | CRef2(): UnPackSize(0), PackSize(0), StartPos(0) {} |
michael@0 | 37 | }; |
michael@0 | 38 | */ |
michael@0 | 39 | |
michael@0 | 40 | struct CVolume |
michael@0 | 41 | { |
michael@0 | 42 | int StartRef2Index; |
michael@0 | 43 | CMyComPtr<IInStream> Stream; |
michael@0 | 44 | CArchiveDatabaseEx Database; |
michael@0 | 45 | }; |
michael@0 | 46 | #endif |
michael@0 | 47 | |
michael@0 | 48 | #ifndef EXTRACT_ONLY |
michael@0 | 49 | |
michael@0 | 50 | struct COneMethodInfo |
michael@0 | 51 | { |
michael@0 | 52 | CObjectVector<CProperty> CoderProperties; |
michael@0 | 53 | UString MethodName; |
michael@0 | 54 | }; |
michael@0 | 55 | #endif |
michael@0 | 56 | |
michael@0 | 57 | // {23170F69-40C1-278A-1000-000110070000} |
michael@0 | 58 | DEFINE_GUID(CLSID_CFormat7z, |
michael@0 | 59 | 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00); |
michael@0 | 60 | |
michael@0 | 61 | #ifndef __7Z_SET_PROPERTIES |
michael@0 | 62 | |
michael@0 | 63 | #ifdef EXTRACT_ONLY |
michael@0 | 64 | #ifdef COMPRESS_MT |
michael@0 | 65 | #define __7Z_SET_PROPERTIES |
michael@0 | 66 | #endif |
michael@0 | 67 | #else |
michael@0 | 68 | #define __7Z_SET_PROPERTIES |
michael@0 | 69 | #endif |
michael@0 | 70 | |
michael@0 | 71 | #endif |
michael@0 | 72 | |
michael@0 | 73 | |
michael@0 | 74 | class CHandler: |
michael@0 | 75 | public IInArchive, |
michael@0 | 76 | #ifdef _7Z_VOL |
michael@0 | 77 | public IInArchiveGetStream, |
michael@0 | 78 | #endif |
michael@0 | 79 | #ifdef __7Z_SET_PROPERTIES |
michael@0 | 80 | public ISetProperties, |
michael@0 | 81 | #endif |
michael@0 | 82 | #ifndef EXTRACT_ONLY |
michael@0 | 83 | public IOutArchive, |
michael@0 | 84 | #endif |
michael@0 | 85 | public CMyUnknownImp |
michael@0 | 86 | { |
michael@0 | 87 | public: |
michael@0 | 88 | MY_QUERYINTERFACE_BEGIN |
michael@0 | 89 | #ifdef _7Z_VOL |
michael@0 | 90 | MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream) |
michael@0 | 91 | #endif |
michael@0 | 92 | #ifdef __7Z_SET_PROPERTIES |
michael@0 | 93 | MY_QUERYINTERFACE_ENTRY(ISetProperties) |
michael@0 | 94 | #endif |
michael@0 | 95 | #ifndef EXTRACT_ONLY |
michael@0 | 96 | MY_QUERYINTERFACE_ENTRY(IOutArchive) |
michael@0 | 97 | #endif |
michael@0 | 98 | MY_QUERYINTERFACE_END |
michael@0 | 99 | MY_ADDREF_RELEASE |
michael@0 | 100 | |
michael@0 | 101 | STDMETHOD(Open)(IInStream *stream, |
michael@0 | 102 | const UInt64 *maxCheckStartPosition, |
michael@0 | 103 | IArchiveOpenCallback *openArchiveCallback); |
michael@0 | 104 | STDMETHOD(Close)(); |
michael@0 | 105 | |
michael@0 | 106 | STDMETHOD(GetNumberOfItems)(UInt32 *numItems); |
michael@0 | 107 | STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value); |
michael@0 | 108 | STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, |
michael@0 | 109 | Int32 testMode, IArchiveExtractCallback *extractCallback); |
michael@0 | 110 | |
michael@0 | 111 | STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value); |
michael@0 | 112 | |
michael@0 | 113 | STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties); |
michael@0 | 114 | STDMETHOD(GetPropertyInfo)(UInt32 index, |
michael@0 | 115 | BSTR *name, PROPID *propID, VARTYPE *varType); |
michael@0 | 116 | |
michael@0 | 117 | STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties); |
michael@0 | 118 | STDMETHOD(GetArchivePropertyInfo)(UInt32 index, |
michael@0 | 119 | BSTR *name, PROPID *propID, VARTYPE *varType); |
michael@0 | 120 | |
michael@0 | 121 | #ifdef _7Z_VOL |
michael@0 | 122 | STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream); |
michael@0 | 123 | #endif |
michael@0 | 124 | |
michael@0 | 125 | #ifdef __7Z_SET_PROPERTIES |
michael@0 | 126 | STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties); |
michael@0 | 127 | #endif |
michael@0 | 128 | |
michael@0 | 129 | #ifndef EXTRACT_ONLY |
michael@0 | 130 | // IOutArchiveHandler |
michael@0 | 131 | STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems, |
michael@0 | 132 | IArchiveUpdateCallback *updateCallback); |
michael@0 | 133 | |
michael@0 | 134 | STDMETHOD(GetFileTimeType)(UInt32 *type); |
michael@0 | 135 | |
michael@0 | 136 | // ISetProperties |
michael@0 | 137 | |
michael@0 | 138 | HRESULT SetSolidSettings(const UString &s); |
michael@0 | 139 | HRESULT SetSolidSettings(const PROPVARIANT &value); |
michael@0 | 140 | #endif |
michael@0 | 141 | |
michael@0 | 142 | CHandler(); |
michael@0 | 143 | |
michael@0 | 144 | private: |
michael@0 | 145 | #ifdef _7Z_VOL |
michael@0 | 146 | CObjectVector<CVolume> _volumes; |
michael@0 | 147 | CObjectVector<CRef> _refs; |
michael@0 | 148 | #else |
michael@0 | 149 | CMyComPtr<IInStream> _inStream; |
michael@0 | 150 | NArchive::N7z::CArchiveDatabaseEx _database; |
michael@0 | 151 | #endif |
michael@0 | 152 | |
michael@0 | 153 | #ifdef COMPRESS_MT |
michael@0 | 154 | UInt32 _numThreads; |
michael@0 | 155 | #endif |
michael@0 | 156 | |
michael@0 | 157 | #ifndef EXTRACT_ONLY |
michael@0 | 158 | CObjectVector<COneMethodInfo> _methods; |
michael@0 | 159 | CRecordVector<CBind> _binds; |
michael@0 | 160 | bool _removeSfxBlock; |
michael@0 | 161 | UInt64 _numSolidFiles; |
michael@0 | 162 | UInt64 _numSolidBytes; |
michael@0 | 163 | bool _numSolidBytesDefined; |
michael@0 | 164 | bool _solidExtension; |
michael@0 | 165 | |
michael@0 | 166 | bool _compressHeaders; |
michael@0 | 167 | bool _compressHeadersFull; |
michael@0 | 168 | bool _encryptHeaders; |
michael@0 | 169 | |
michael@0 | 170 | bool _autoFilter; |
michael@0 | 171 | UInt32 _level; |
michael@0 | 172 | |
michael@0 | 173 | bool _volumeMode; |
michael@0 | 174 | |
michael@0 | 175 | |
michael@0 | 176 | HRESULT SetParam(COneMethodInfo &oneMethodInfo, const UString &name, const UString &value); |
michael@0 | 177 | HRESULT SetParams(COneMethodInfo &oneMethodInfo, const UString &srcString); |
michael@0 | 178 | |
michael@0 | 179 | HRESULT SetPassword(CCompressionMethodMode &methodMode, |
michael@0 | 180 | IArchiveUpdateCallback *updateCallback); |
michael@0 | 181 | |
michael@0 | 182 | HRESULT SetCompressionMethod(CCompressionMethodMode &method, |
michael@0 | 183 | CObjectVector<COneMethodInfo> &methodsInfo |
michael@0 | 184 | #ifdef COMPRESS_MT |
michael@0 | 185 | , UInt32 numThreads |
michael@0 | 186 | #endif |
michael@0 | 187 | ); |
michael@0 | 188 | |
michael@0 | 189 | HRESULT SetCompressionMethod( |
michael@0 | 190 | CCompressionMethodMode &method, |
michael@0 | 191 | CCompressionMethodMode &headerMethod); |
michael@0 | 192 | |
michael@0 | 193 | #endif |
michael@0 | 194 | |
michael@0 | 195 | #ifndef _SFX |
michael@0 | 196 | |
michael@0 | 197 | CRecordVector<UInt64> _fileInfoPopIDs; |
michael@0 | 198 | void FillPopIDs(); |
michael@0 | 199 | |
michael@0 | 200 | #endif |
michael@0 | 201 | |
michael@0 | 202 | #ifndef EXTRACT_ONLY |
michael@0 | 203 | |
michael@0 | 204 | void InitSolidFiles() { _numSolidFiles = UInt64(Int64(-1)); } |
michael@0 | 205 | void InitSolidSize() { _numSolidBytes = UInt64(Int64(-1)); } |
michael@0 | 206 | void InitSolid() |
michael@0 | 207 | { |
michael@0 | 208 | InitSolidFiles(); |
michael@0 | 209 | InitSolidSize(); |
michael@0 | 210 | _solidExtension = false; |
michael@0 | 211 | _numSolidBytesDefined = false; |
michael@0 | 212 | } |
michael@0 | 213 | |
michael@0 | 214 | void Init() |
michael@0 | 215 | { |
michael@0 | 216 | _removeSfxBlock = false; |
michael@0 | 217 | _compressHeaders = true; |
michael@0 | 218 | _compressHeadersFull = true; |
michael@0 | 219 | _encryptHeaders = false; |
michael@0 | 220 | #ifdef COMPRESS_MT |
michael@0 | 221 | _numThreads = NWindows::NSystem::GetNumberOfProcessors(); |
michael@0 | 222 | #endif |
michael@0 | 223 | |
michael@0 | 224 | _level = 5; |
michael@0 | 225 | _autoFilter = true; |
michael@0 | 226 | _volumeMode = false; |
michael@0 | 227 | InitSolid(); |
michael@0 | 228 | } |
michael@0 | 229 | #endif |
michael@0 | 230 | }; |
michael@0 | 231 | |
michael@0 | 232 | }} |
michael@0 | 233 | |
michael@0 | 234 | #endif |