• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 7z/Handler.h
2 
3 #ifndef __7Z_HANDLER_H
4 #define __7Z_HANDLER_H
5 
6 #include "../../ICoder.h"
7 #include "../IArchive.h"
8 
9 #include "../../Common/CreateCoder.h"
10 
11 #ifndef EXTRACT_ONLY
12 #include "../Common/HandlerOut.h"
13 #endif
14 
15 #include "7zCompressionMode.h"
16 #include "7zIn.h"
17 
18 namespace NArchive {
19 namespace N7z {
20 
21 const UInt32 k_Copy = 0x0;
22 const UInt32 k_Delta = 3;
23 const UInt32 k_LZMA2 = 0x21;
24 const UInt32 k_LZMA  = 0x030101;
25 const UInt32 k_PPMD  = 0x030401;
26 const UInt32 k_BCJ  = 0x03030103;
27 const UInt32 k_BCJ2 = 0x0303011B;
28 const UInt32 k_Deflate = 0x040108;
29 const UInt32 k_BZip2   = 0x040202;
30 
31 #ifndef __7Z_SET_PROPERTIES
32 
33 #ifdef EXTRACT_ONLY
34 #if !defined(_7ZIP_ST) && !defined(_SFX)
35 #define __7Z_SET_PROPERTIES
36 #endif
37 #else
38 #define __7Z_SET_PROPERTIES
39 #endif
40 
41 #endif
42 
43 
44 #ifndef EXTRACT_ONLY
45 
46 class COutHandler: public CMultiMethodProps
47 {
48   HRESULT SetSolidFromString(const UString &s);
49   HRESULT SetSolidFromPROPVARIANT(const PROPVARIANT &value);
50 public:
51   bool _removeSfxBlock;
52 
53   UInt64 _numSolidFiles;
54   UInt64 _numSolidBytes;
55   bool _numSolidBytesDefined;
56   bool _solidExtension;
57 
58   bool _compressHeaders;
59   bool _encryptHeadersSpecified;
60   bool _encryptHeaders;
61   // bool _useParents; 9.26
62 
63   CBoolPair Write_CTime;
64   CBoolPair Write_ATime;
65   CBoolPair Write_MTime;
66 
67   bool _volumeMode;
68 
InitSolidFiles()69   void InitSolidFiles() { _numSolidFiles = (UInt64)(Int64)(-1); }
InitSolidSize()70   void InitSolidSize()  { _numSolidBytes = (UInt64)(Int64)(-1); }
InitSolid()71   void InitSolid()
72   {
73     InitSolidFiles();
74     InitSolidSize();
75     _solidExtension = false;
76     _numSolidBytesDefined = false;
77   }
78 
79   void InitProps();
80 
COutHandler()81   COutHandler() { InitProps(); }
82 
83   HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
84 };
85 
86 #endif
87 
88 class CHandler:
89   public IInArchive,
90   public IArchiveGetRawProps,
91   #ifdef __7Z_SET_PROPERTIES
92   public ISetProperties,
93   #endif
94   #ifndef EXTRACT_ONLY
95   public IOutArchive,
96   #endif
97   PUBLIC_ISetCompressCodecsInfo
98   public CMyUnknownImp
99   #ifndef EXTRACT_ONLY
100   , public COutHandler
101   #endif
102 {
103 public:
104   MY_QUERYINTERFACE_BEGIN2(IInArchive)
105   MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps)
106   #ifdef __7Z_SET_PROPERTIES
107   MY_QUERYINTERFACE_ENTRY(ISetProperties)
108   #endif
109   #ifndef EXTRACT_ONLY
110   MY_QUERYINTERFACE_ENTRY(IOutArchive)
111   #endif
112   QUERY_ENTRY_ISetCompressCodecsInfo
113   MY_QUERYINTERFACE_END
114   MY_ADDREF_RELEASE
115 
116   INTERFACE_IInArchive(;)
117   INTERFACE_IArchiveGetRawProps(;)
118 
119   #ifdef __7Z_SET_PROPERTIES
120   STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, UInt32 numProps);
121   #endif
122 
123   #ifndef EXTRACT_ONLY
124   INTERFACE_IOutArchive(;)
125   #endif
126 
127   DECL_ISetCompressCodecsInfo
128 
129   CHandler();
130 
131 private:
132   CMyComPtr<IInStream> _inStream;
133   NArchive::N7z::CDbEx _db;
134   #ifndef _NO_CRYPTO
135   bool _isEncrypted;
136   bool _passwordIsDefined;
137   #endif
138 
139   #ifdef EXTRACT_ONLY
140 
141   #ifdef __7Z_SET_PROPERTIES
142   UInt32 _numThreads;
143   #endif
144 
145   UInt32 _crcSize;
146 
147   #else
148 
149   CRecordVector<CBind> _binds;
150 
151   HRESULT PropsMethod_To_FullMethod(CMethodFull &dest, const COneMethodInfo &m);
152   HRESULT SetHeaderMethod(CCompressionMethodMode &headerMethod);
153   void AddDefaultMethod();
154   HRESULT SetMainMethod(CCompressionMethodMode &method,
155       CObjectVector<COneMethodInfo> &methodsInfo
156       #ifndef _7ZIP_ST
157       , UInt32 numThreads
158       #endif
159       );
160 
161 
162   #endif
163 
164   bool IsFolderEncrypted(CNum folderIndex) const;
165   #ifndef _SFX
166 
167   CRecordVector<UInt64> _fileInfoPopIDs;
168   void FillPopIDs();
169   void AddMethodName(AString &s, UInt64 id);
170   HRESULT SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const;
171 
172   #endif
173 
174   DECL_EXTERNAL_CODECS_VARS
175 };
176 
177 }}
178 
179 #endif
180