xref: /aosp_15_r20/external/lzma/CPP/7zip/Archive/Zip/ZipAddCommon.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // ZipAddCommon.h
2 
3 #ifndef ZIP7_INC_ZIP_ADD_COMMON_H
4 #define ZIP7_INC_ZIP_ADD_COMMON_H
5 
6 #include "../../ICoder.h"
7 #include "../../IProgress.h"
8 
9 #include "../../Common/CreateCoder.h"
10 #include "../../Common/FilterCoder.h"
11 
12 #include "../../Compress/CopyCoder.h"
13 
14 #include "../../Crypto/ZipCrypto.h"
15 #include "../../Crypto/WzAes.h"
16 
17 #include "ZipCompressionMode.h"
18 
19 namespace NArchive {
20 namespace NZip {
21 
22 struct CCompressingResult
23 {
24   UInt64 UnpackSize;
25   UInt64 PackSize;
26   UInt32 CRC;
27   UInt16 Method;
28   Byte ExtractVersion;
29   bool DescriptorMode;
30   bool LzmaEos;
31 
CCompressingResultCCompressingResult32   CCompressingResult()
33   {
34     // for GCC:
35     UnpackSize = 0;
36   }
37 };
38 
39 class CAddCommon  MY_UNCOPYABLE
40 {
41   CCompressionMethodMode _options;
42   CMyComPtr2<ICompressCoder, NCompress::CCopyCoder> _copyCoder;
43 
44   CMyComPtr<ICompressCoder> _compressEncoder;
45   Byte _compressExtractVersion;
46   bool _isLzmaEos;
47 
48   CMyComPtr2<ISequentialOutStream, CFilterCoder> _cryptoStream;
49 
50   NCrypto::NZip::CEncoder *_filterSpec;
51   NCrypto::NWzAes::CEncoder *_filterAesSpec;
52 
53   Byte *_buf;
54 
55   HRESULT CalcStreamCRC(ISequentialInStream *inStream, UInt32 &resultCRC);
56 public:
57   // CAddCommon(const CCompressionMethodMode &options);
58   CAddCommon();
59   void SetOptions(const CCompressionMethodMode &options);
60   ~CAddCommon();
61 
62   HRESULT Set_Pre_CompressionResult(bool inSeqMode, bool outSeqMode, UInt64 unpackSize,
63       CCompressingResult &opRes) const;
64 
65   HRESULT Compress(
66       DECL_EXTERNAL_CODECS_LOC_VARS
67       ISequentialInStream *inStream, IOutStream *outStream,
68       bool inSeqMode, bool outSeqMode,
69       UInt32 fileTime,
70       UInt64 expectedDataSize, bool expectedDataSize_IsConfirmed,
71       ICompressProgressInfo *progress, CCompressingResult &opRes);
72 };
73 
74 }}
75 
76 #endif
77