mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-13 12:11:38 -06:00
Update to 7-Zip Version 21.02
This commit is contained in:
@@ -89,14 +89,18 @@ STDMETHODIMP CLzmaEncoder::Code(ISequentialInStream *inStream, ISequentialOutStr
|
||||
}
|
||||
|
||||
|
||||
CAddCommon::CAddCommon(const CCompressionMethodMode &options):
|
||||
_options(options),
|
||||
CAddCommon::CAddCommon():
|
||||
_copyCoderSpec(NULL),
|
||||
_isLzmaEos(false),
|
||||
_cryptoStreamSpec(NULL),
|
||||
_buf(NULL),
|
||||
_isLzmaEos(false)
|
||||
_buf(NULL)
|
||||
{}
|
||||
|
||||
void CAddCommon::SetOptions(const CCompressionMethodMode &options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
CAddCommon::~CAddCommon()
|
||||
{
|
||||
MidFree(_buf);
|
||||
@@ -232,6 +236,11 @@ HRESULT CAddCommon::Compress(
|
||||
unsigned numTestMethods = _options.MethodSequence.Size();
|
||||
|
||||
bool descriptorMode = outSeqMode;
|
||||
|
||||
// ZipCrypto without descriptor requires additional reading pass for
|
||||
// inStream to calculate CRC for password check field.
|
||||
// The descriptor allows to use ZipCrypto check field without CRC (InfoZip's modification).
|
||||
|
||||
if (!outSeqMode)
|
||||
if (inSeqMode && _options.PasswordIsDefined && !_options.IsAesMode)
|
||||
descriptorMode = true;
|
||||
@@ -264,6 +273,15 @@ HRESULT CAddCommon::Compress(
|
||||
RINOK(outStream->SetSize(0));
|
||||
RINOK(outStream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
}
|
||||
|
||||
method = _options.MethodSequence[i];
|
||||
if (method == NCompressionMethod::kStore && descriptorMode)
|
||||
{
|
||||
// we still can create descriptor_mode archives with "Store" method, but they are not good for 100%
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
bool needCode = true;
|
||||
|
||||
if (_options.PasswordIsDefined)
|
||||
{
|
||||
@@ -316,23 +334,25 @@ HRESULT CAddCommon::Compress(
|
||||
RINOK(_filterSpec->WriteHeader_Check16(outStream, (UInt16)check));
|
||||
}
|
||||
|
||||
RINOK(_cryptoStreamSpec->SetOutStream(outStream));
|
||||
RINOK(_cryptoStreamSpec->InitEncoder());
|
||||
outStreamReleaser.FilterCoder = _cryptoStreamSpec;
|
||||
if (method == NCompressionMethod::kStore)
|
||||
{
|
||||
needCode = false;
|
||||
RINOK(_cryptoStreamSpec->Code(inCrcStream, outStream, NULL, NULL, progress));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(_cryptoStreamSpec->SetOutStream(outStream));
|
||||
RINOK(_cryptoStreamSpec->InitEncoder());
|
||||
outStreamReleaser.FilterCoder = _cryptoStreamSpec;
|
||||
}
|
||||
}
|
||||
|
||||
method = _options.MethodSequence[i];
|
||||
|
||||
switch (method)
|
||||
if (needCode)
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
case NCompressionMethod::kStore:
|
||||
{
|
||||
if (descriptorMode)
|
||||
{
|
||||
// we still can create descriptor_mode archives with "Store" method, but they are not good for 100%
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if (!_copyCoderSpec)
|
||||
{
|
||||
_copyCoderSpec = new NCompress::CCopyCoder;
|
||||
@@ -446,15 +466,21 @@ HRESULT CAddCommon::Compress(
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
RINOK(_compressEncoder->Code(inCrcStream, outStreamNew, NULL, NULL, progress));
|
||||
} catch (...) { return E_FAIL; }
|
||||
break;
|
||||
}
|
||||
} // switch end
|
||||
|
||||
if (_options.PasswordIsDefined)
|
||||
{
|
||||
RINOK(_cryptoStreamSpec->OutStreamFinish());
|
||||
}
|
||||
}
|
||||
|
||||
if (_options.PasswordIsDefined)
|
||||
{
|
||||
RINOK(_cryptoStreamSpec->OutStreamFinish());
|
||||
|
||||
if (_options.IsAesMode)
|
||||
{
|
||||
RINOK(_filterAesSpec->WriteFooter(outStream));
|
||||
|
||||
Reference in New Issue
Block a user