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