1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// NsisDecode.h
#ifndef __NSIS_DECODE_H
#define __NSIS_DECODE_H
#include "../../../Common/MyBuffer.h"
#include "../../Common/FilterCoder.h"
#include "../../Common/StreamUtils.h"
#include "../../Compress/LzmaDecoder.h"
namespace NArchive {
namespace NNsis {
namespace NMethodType
{
enum EEnum
{
kCopy,
kDeflate,
kBZip2,
kLZMA
};
}
/* 7-Zip installers 4.38 - 9.08 used modified version of NSIS that
supported BCJ filter for better compression ratio.
We support such modified NSIS archives. */
class CDecoder
{
NMethodType::EEnum _curMethod; // method of created decoder
CFilterCoder *_filter;
CMyComPtr<ISequentialInStream> _filterInStream;
CMyComPtr<ISequentialInStream> _codecInStream;
CMyComPtr<ISequentialInStream> _decoderInStream;
NCompress::NLzma::CDecoder *_lzmaDecoder;
public:
CMyComPtr<IInStream> InputStream; // for non-solid
UInt64 StreamPos; // the pos in unpacked for solid, the pos in Packed for non-solid
NMethodType::EEnum Method;
bool FilterFlag;
bool Solid;
CByteBuffer Buffer; // temp buf.
void Release()
{
_filterInStream.Release();
_codecInStream.Release();
_decoderInStream.Release();
InputStream.Release();
_lzmaDecoder = NULL;
}
HRESULT Init(ISequentialInStream *inStream, bool &useFilter);
HRESULT Read(void *data, size_t *processedSize)
{
return ReadStream(_decoderInStream, data, processedSize);;
}
HRESULT SetToPos(UInt64 pos, ICompressProgressInfo *progress); // for solid
HRESULT Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unpackSize,
ISequentialOutStream *realOutStream, ICompressProgressInfo *progress,
UInt32 &packSizeRes, UInt32 &unpackSizeRes);
};
}}
#endif
|