mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 12:07:08 -06:00
9.34
This commit is contained in:
committed by
Kornel Lesiński
parent
83f8ddcc5b
commit
f08f4dcc3c
33
CPP/7zip/Compress/ZlibDecoder.h
Executable file → Normal file
33
CPP/7zip/Compress/ZlibDecoder.h
Executable file → Normal file
@@ -16,13 +16,15 @@ class COutStreamWithAdler:
|
||||
{
|
||||
CMyComPtr<ISequentialOutStream> _stream;
|
||||
UInt32 _adler;
|
||||
UInt64 _size;
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
void Init() { _adler = ADLER_INIT_VAL; }
|
||||
void Init() { _adler = ADLER_INIT_VAL; _size = 0; }
|
||||
UInt32 GetAdler() const { return _adler; }
|
||||
UInt64 GetSize() const { return _size; }
|
||||
};
|
||||
|
||||
class CDecoder:
|
||||
@@ -39,10 +41,39 @@ public:
|
||||
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
|
||||
|
||||
UInt64 GetInputProcessedSize() const { return DeflateDecoderSpec->GetInputProcessedSize() + 2; }
|
||||
UInt64 GetOutputProcessedSize() const { return AdlerSpec->GetSize(); }
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
};
|
||||
|
||||
static bool inline IsZlib(const Byte *p)
|
||||
{
|
||||
if ((p[0] & 0xF) != 8) // method
|
||||
return false;
|
||||
if (((unsigned)p[0] >> 4) > 7) // logar_window_size minus 8.
|
||||
return false;
|
||||
if ((p[1] & 0x20) != 0) // dictPresent
|
||||
return false;
|
||||
if ((((UInt32)p[0] << 8) + p[1]) % 31 != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// IsZlib_3bytes checks 2 bytes of zlib header and starting byte of Deflate stream
|
||||
|
||||
static bool inline IsZlib_3bytes(const Byte *p)
|
||||
{
|
||||
if (!IsZlib(p))
|
||||
return false;
|
||||
unsigned val = p[2];
|
||||
unsigned blockType = (val >> 1) & 0x3;
|
||||
if (blockType == 3) // unsupported block type for deflate
|
||||
return false;
|
||||
if (blockType == NCompress::NDeflate::NBlockType::kStored && (val >> 3) != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user