mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 14:07:00 -06:00
Update to 7-Zip 16.03
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
|
||||
#include "../../Compress/BcjCoder.h"
|
||||
#include "../../Compress/BZip2Decoder.h"
|
||||
#include "../../Compress/DeflateDecoder.h"
|
||||
|
||||
#define Get32(p) GetUi32(p)
|
||||
|
||||
@@ -27,12 +26,16 @@ HRESULT CDecoder::Init(ISequentialInStream *inStream, bool &useFilter)
|
||||
if (Method != _curMethod)
|
||||
Release();
|
||||
_curMethod = Method;
|
||||
|
||||
if (!_codecInStream)
|
||||
{
|
||||
switch (Method)
|
||||
{
|
||||
// case NMethodType::kCopy: return E_NOTIMPL;
|
||||
case NMethodType::kDeflate: _codecInStream = new NCompress::NDeflate::NDecoder::CNsisCOMCoder(); break;
|
||||
case NMethodType::kDeflate:
|
||||
_deflateDecoder = new NCompress::NDeflate::NDecoder::CCOMCoder();
|
||||
_codecInStream = _deflateDecoder;
|
||||
break;
|
||||
case NMethodType::kBZip2: _codecInStream = new NCompress::NBZip2::CNsisDecoder(); break;
|
||||
case NMethodType::kLZMA:
|
||||
_lzmaDecoder = new NCompress::NLzma::CDecoder();
|
||||
@@ -42,6 +45,9 @@ HRESULT CDecoder::Init(ISequentialInStream *inStream, bool &useFilter)
|
||||
}
|
||||
}
|
||||
|
||||
if (Method == NMethodType::kDeflate)
|
||||
_deflateDecoder->SetNsisMode(IsNsisDeflate);
|
||||
|
||||
if (FilterFlag)
|
||||
{
|
||||
Byte flag;
|
||||
@@ -199,9 +205,8 @@ HRESULT CDecoder::Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unp
|
||||
|
||||
if (outBuf)
|
||||
{
|
||||
if (!unpackSizeDefined)
|
||||
return S_FALSE;
|
||||
outBuf->Alloc(unpackSize);
|
||||
if (unpackSizeDefined)
|
||||
outBuf->Alloc(unpackSize);
|
||||
}
|
||||
|
||||
UInt64 inSizeStart = 0;
|
||||
@@ -213,6 +218,8 @@ HRESULT CDecoder::Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unp
|
||||
unpackSize = 0xFFFFFFFF;
|
||||
UInt32 offset = 0;
|
||||
|
||||
HRESULT res = S_OK;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
size_t rem = unpackSize - offset;
|
||||
@@ -225,11 +232,25 @@ HRESULT CDecoder::Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unp
|
||||
if (size == 0)
|
||||
{
|
||||
if (unpackSizeDefined)
|
||||
return S_FALSE;
|
||||
res = S_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (outBuf)
|
||||
{
|
||||
size_t nextSize = offset + size;
|
||||
if (outBuf->Size() < nextSize)
|
||||
{
|
||||
{
|
||||
const size_t nextSize2 = outBuf->Size() * 2;
|
||||
if (nextSize < nextSize2)
|
||||
nextSize = nextSize2;
|
||||
}
|
||||
outBuf->ChangeSize_KeepData(nextSize, offset);
|
||||
}
|
||||
memcpy((Byte *)*outBuf + (size_t)offset, Buffer, size);
|
||||
}
|
||||
|
||||
StreamPos += size;
|
||||
offset += (UInt32)size;
|
||||
|
||||
@@ -243,9 +264,17 @@ HRESULT CDecoder::Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unp
|
||||
UInt64 outSize = offset;
|
||||
RINOK(progress->SetRatioInfo(&inSize, &outSize));
|
||||
if (realOutStream)
|
||||
RINOK(WriteStream(realOutStream, Buffer, size));
|
||||
{
|
||||
res = WriteStream(realOutStream, Buffer, size);
|
||||
if (res != S_OK)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
if (outBuf && offset != outBuf->Size())
|
||||
outBuf->ChangeSize_KeepData(offset, offset);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "../../Common/FilterCoder.h"
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "../../Compress/DeflateDecoder.h"
|
||||
#include "../../Compress/LzmaDecoder.h"
|
||||
|
||||
namespace NArchive {
|
||||
@@ -37,6 +38,7 @@ class CDecoder
|
||||
CMyComPtr<ISequentialInStream> _codecInStream;
|
||||
CMyComPtr<ISequentialInStream> _decoderInStream;
|
||||
|
||||
NCompress::NDeflate::NDecoder::CCOMCoder *_deflateDecoder;
|
||||
NCompress::NLzma::CDecoder *_lzmaDecoder;
|
||||
|
||||
public:
|
||||
@@ -46,9 +48,16 @@ public:
|
||||
NMethodType::EEnum Method;
|
||||
bool FilterFlag;
|
||||
bool Solid;
|
||||
bool IsNsisDeflate;
|
||||
|
||||
CByteBuffer Buffer; // temp buf.
|
||||
|
||||
CDecoder():
|
||||
FilterFlag(false),
|
||||
Solid(true),
|
||||
IsNsisDeflate(true)
|
||||
{}
|
||||
|
||||
void Release()
|
||||
{
|
||||
_filterInStream.Release();
|
||||
|
||||
@@ -175,7 +175,7 @@ static const CCommandInfo k_Commands[kNumCmds] =
|
||||
{ 0 }, // "BringToFront" },
|
||||
{ 2 }, // "SetDetailsView" },
|
||||
{ 2 }, // "SetFileAttributes" },
|
||||
{ 2 }, // CreateDirectory, SetOutPath
|
||||
{ 3 }, // CreateDirectory, SetOutPath
|
||||
{ 3 }, // "IfFileExists" },
|
||||
{ 3 }, // SetRebootFlag, ...
|
||||
{ 4 }, // "If" }, // IfAbort, IfSilent, IfErrors, IfRebootFlag
|
||||
@@ -1395,7 +1395,7 @@ void CInArchive::AddRegRoot(UInt32 val)
|
||||
Script += s;
|
||||
}
|
||||
|
||||
static const char *g_WinAttrib[] =
|
||||
static const char * const g_WinAttrib[] =
|
||||
{
|
||||
"READONLY"
|
||||
, "HIDDEN"
|
||||
@@ -3362,6 +3362,11 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
#ifdef NSIS_SCRIPT
|
||||
s += isSetOutPath ? "SetOutPath" : "CreateDirectory";
|
||||
AddParam(params[0]);
|
||||
if (params[2] != 0)
|
||||
{
|
||||
SmallSpaceComment();
|
||||
s += "CreateRestrictedDirectory";
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
@@ -3378,11 +3383,8 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
params[2] == 0 &&
|
||||
params[3] == 0)
|
||||
{
|
||||
if (IsVarStr(params[1], kVar_OUTDIR))
|
||||
{
|
||||
spec_outdir_U = UPrefixes.Back(); // outdir_U;
|
||||
spec_outdir_A = APrefixes.Back();// outdir_A;
|
||||
}
|
||||
spec_outdir_U = UPrefixes.Back(); // outdir_U;
|
||||
spec_outdir_A = APrefixes.Back(); // outdir_A;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5045,6 +5047,9 @@ HRESULT CInArchive::Parse()
|
||||
|
||||
DetectNsisType(bhEntries, _data + bhEntries.Offset);
|
||||
|
||||
Decoder.IsNsisDeflate = (NsisType != k_NsisType_Nsis3);
|
||||
|
||||
|
||||
#ifdef NSIS_SCRIPT
|
||||
|
||||
{
|
||||
@@ -5606,6 +5611,9 @@ HRESULT CInArchive::Open2(const Byte *sig, size_t size)
|
||||
Decoder.Method = Method;
|
||||
Decoder.FilterFlag = FilterFlag;
|
||||
Decoder.Solid = IsSolid;
|
||||
|
||||
Decoder.IsNsisDeflate = true; // we need some smart check that NSIS is not NSIS3 here.
|
||||
|
||||
Decoder.InputStream = _stream;
|
||||
Decoder.Buffer.Alloc(kInputBufSize);
|
||||
Decoder.StreamPos = 0;
|
||||
|
||||
Reference in New Issue
Block a user