mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 00:07:06 -06:00
Update to 7-Zip Version 18.05
This commit is contained in:
@@ -13,7 +13,9 @@ struct CMethodFull: public CMethodProps
|
||||
{
|
||||
CMethodId Id;
|
||||
UInt32 NumStreams;
|
||||
int CodecIndex;
|
||||
|
||||
CMethodFull(): CodecIndex(-1) {}
|
||||
bool IsSimpleCoder() const { return NumStreams == 1; }
|
||||
};
|
||||
|
||||
|
||||
@@ -236,8 +236,8 @@ HRESULT CDecoder::Decode(
|
||||
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
|
||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
||||
, bool mtMode, UInt32 numThreads
|
||||
#if !defined(_7ZIP_ST)
|
||||
, bool mtMode, UInt32 numThreads, UInt64 memUsage
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@@ -312,7 +312,7 @@ HRESULT CDecoder::Decode(
|
||||
#endif
|
||||
|
||||
CCreatedCoder cod;
|
||||
RINOK(CreateCoder(
|
||||
RINOK(CreateCoder_Id(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
coderInfo.MethodID, false, cod));
|
||||
|
||||
@@ -355,11 +355,39 @@ HRESULT CDecoder::Decode(
|
||||
|
||||
unsigned i;
|
||||
|
||||
bool mt_wasUsed = false;
|
||||
|
||||
for (i = 0; i < folderInfo.Coders.Size(); i++)
|
||||
{
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
IUnknown *decoder = _mixer->GetCoder(i).GetUnknown();
|
||||
|
||||
#if !defined(_7ZIP_ST)
|
||||
if (!mt_wasUsed)
|
||||
{
|
||||
if (mtMode)
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
||||
decoder->QueryInterface(IID_ICompressSetCoderMt, (void **)&setCoderMt);
|
||||
if (setCoderMt)
|
||||
{
|
||||
mt_wasUsed = true;
|
||||
RINOK(setCoderMt->SetNumberOfThreads(numThreads));
|
||||
}
|
||||
}
|
||||
// if (memUsage != 0)
|
||||
{
|
||||
CMyComPtr<ICompressSetMemLimit> setMemLimit;
|
||||
decoder->QueryInterface(IID_ICompressSetMemLimit, (void **)&setMemLimit);
|
||||
if (setMemLimit)
|
||||
{
|
||||
mt_wasUsed = true;
|
||||
RINOK(setMemLimit->SetMemLimit(memUsage));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
|
||||
decoder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
|
||||
@@ -376,18 +404,6 @@ HRESULT CDecoder::Decode(
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
||||
if (mtMode)
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
||||
decoder->QueryInterface(IID_ICompressSetCoderMt, (void **)&setCoderMt);
|
||||
if (setCoderMt)
|
||||
{
|
||||
RINOK(setCoderMt->SetNumberOfThreads(numThreads));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
{
|
||||
CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
|
||||
|
||||
@@ -59,8 +59,8 @@ public:
|
||||
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
|
||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
||||
, bool mtMode, UInt32 numThreads
|
||||
#if !defined(_7ZIP_ST)
|
||||
, bool mtMode, UInt32 numThreads, UInt64 memUsage
|
||||
#endif
|
||||
);
|
||||
};
|
||||
|
||||
@@ -154,9 +154,18 @@ HRESULT CEncoder::CreateMixerCoder(
|
||||
|
||||
CCreatedCoder cod;
|
||||
|
||||
RINOK(CreateCoder(
|
||||
if (methodFull.CodecIndex >= 0)
|
||||
{
|
||||
RINOK(CreateCoder_Index(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
methodFull.CodecIndex, true, cod));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(CreateCoder_Id(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
methodFull.Id, true, cod));
|
||||
}
|
||||
|
||||
if (cod.NumStreams != methodFull.NumStreams)
|
||||
return E_FAIL;
|
||||
|
||||
@@ -152,6 +152,12 @@ STDMETHODIMP CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *proc
|
||||
if (_fileIsOpen)
|
||||
{
|
||||
UInt32 cur = (size < _rem ? size : (UInt32)_rem);
|
||||
if (_calcCrc)
|
||||
{
|
||||
const UInt32 k_Step = (UInt32)1 << 20;
|
||||
if (cur > k_Step)
|
||||
cur = k_Step;
|
||||
}
|
||||
HRESULT result = S_OK;
|
||||
if (_stream)
|
||||
result = _stream->Write(data, cur, &cur);
|
||||
@@ -363,8 +369,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
, dataAfterEnd_Error
|
||||
|
||||
_7Z_DECODER_CRYPRO_VARS
|
||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
||||
, true, _numThreads
|
||||
#if !defined(_7ZIP_ST)
|
||||
, true, _numThreads, _memUsage
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ CHandler::CHandler()
|
||||
_crcSize = 4;
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
_numThreads = NSystem::GetNumberOfProcessors();
|
||||
_useMultiThreadMixer = true;
|
||||
#endif
|
||||
|
||||
@@ -823,8 +822,8 @@ STDMETHODIMP CHandler::Close()
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
|
||||
_numThreads = numProcessors;
|
||||
|
||||
InitCommon();
|
||||
_useMultiThreadMixer = true;
|
||||
|
||||
for (UInt32 i = 0; i < numProps; i++)
|
||||
@@ -843,13 +842,15 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
||||
RINOK(PROPVARIANT_to_bool(value, _useMultiThreadMixer));
|
||||
continue;
|
||||
}
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||
{
|
||||
RINOK(ParseMtProp(name.Ptr(2), value, numProcessors, _numThreads));
|
||||
continue;
|
||||
HRESULT hres;
|
||||
if (SetCommonProperty(name, value, hres))
|
||||
{
|
||||
RINOK(hres);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
@@ -8,16 +8,6 @@
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
#include "../Common/HandlerOut.h"
|
||||
#endif
|
||||
|
||||
#include "7zCompressionMode.h"
|
||||
#include "7zIn.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
#ifndef __7Z_SET_PROPERTIES
|
||||
|
||||
#ifdef EXTRACT_ONLY
|
||||
@@ -30,6 +20,16 @@ namespace N7z {
|
||||
|
||||
#endif
|
||||
|
||||
// #ifdef __7Z_SET_PROPERTIES
|
||||
#include "../Common/HandlerOut.h"
|
||||
// #endif
|
||||
|
||||
#include "7zCompressionMode.h"
|
||||
#include "7zIn.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
|
||||
@@ -38,8 +38,6 @@ class COutHandler: public CMultiMethodProps
|
||||
HRESULT SetSolidFromString(const UString &s);
|
||||
HRESULT SetSolidFromPROPVARIANT(const PROPVARIANT &value);
|
||||
public:
|
||||
bool _removeSfxBlock;
|
||||
|
||||
UInt64 _numSolidFiles;
|
||||
UInt64 _numSolidBytes;
|
||||
bool _numSolidBytesDefined;
|
||||
@@ -58,6 +56,8 @@ public:
|
||||
|
||||
bool _useMultiThreadMixer;
|
||||
|
||||
bool _removeSfxBlock;
|
||||
|
||||
// bool _volumeMode;
|
||||
|
||||
void InitSolidFiles() { _numSolidFiles = (UInt64)(Int64)(-1); }
|
||||
@@ -70,9 +70,10 @@ public:
|
||||
_numSolidBytesDefined = false;
|
||||
}
|
||||
|
||||
void InitProps7z();
|
||||
void InitProps();
|
||||
|
||||
COutHandler() { InitProps(); }
|
||||
COutHandler() { InitProps7z(); }
|
||||
|
||||
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
|
||||
};
|
||||
@@ -82,16 +83,23 @@ public:
|
||||
class CHandler:
|
||||
public IInArchive,
|
||||
public IArchiveGetRawProps,
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
public ISetProperties,
|
||||
#endif
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
public IOutArchive,
|
||||
#endif
|
||||
|
||||
PUBLIC_ISetCompressCodecsInfo
|
||||
public CMyUnknownImp
|
||||
|
||||
public CMyUnknownImp,
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
, public COutHandler
|
||||
public COutHandler
|
||||
#else
|
||||
public CCommonMethodProps
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
@@ -135,7 +143,6 @@ private:
|
||||
#ifdef EXTRACT_ONLY
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
UInt32 _numThreads;
|
||||
bool _useMultiThreadMixer;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "7zOut.h"
|
||||
#include "7zUpdate.h"
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
@@ -41,9 +43,11 @@ STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
|
||||
|
||||
HRESULT CHandler::PropsMethod_To_FullMethod(CMethodFull &dest, const COneMethodInfo &m)
|
||||
{
|
||||
if (!FindMethod(
|
||||
dest.CodecIndex = FindMethod_Index(
|
||||
EXTERNAL_CODECS_VARS
|
||||
m.MethodName, dest.Id, dest.NumStreams))
|
||||
m.MethodName, true,
|
||||
dest.Id, dest.NumStreams);
|
||||
if (dest.CodecIndex < 0)
|
||||
return E_INVALIDARG;
|
||||
(CProps &)dest = (CProps &)m;
|
||||
return S_OK;
|
||||
@@ -700,10 +704,8 @@ static HRESULT ParseBond(UString &srcString, UInt32 &coder, UInt32 &stream)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void COutHandler::InitProps()
|
||||
void COutHandler::InitProps7z()
|
||||
{
|
||||
CMultiMethodProps::Init();
|
||||
|
||||
_removeSfxBlock = false;
|
||||
_compressHeaders = true;
|
||||
_encryptHeadersSpecified = false;
|
||||
@@ -723,6 +725,14 @@ void COutHandler::InitProps()
|
||||
_useTypeSorting = false;
|
||||
}
|
||||
|
||||
void COutHandler::InitProps()
|
||||
{
|
||||
CMultiMethodProps::Init();
|
||||
InitProps7z();
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT COutHandler::SetSolidFromString(const UString &s)
|
||||
{
|
||||
UString s2 = s;
|
||||
@@ -763,6 +773,10 @@ HRESULT COutHandler::SetSolidFromString(const UString &s)
|
||||
}
|
||||
_numSolidBytes = (v << numBits);
|
||||
_numSolidBytesDefined = true;
|
||||
/*
|
||||
if (_numSolidBytes == 0)
|
||||
_numSolidFiles = 1;
|
||||
*/
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
@@ -811,7 +825,7 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
|
||||
return E_INVALIDARG;
|
||||
return SetSolidFromString(name);
|
||||
}
|
||||
|
||||
|
||||
UInt32 number;
|
||||
int index = ParseStringToUInt32(name, number);
|
||||
// UString realName = name.Ptr(index);
|
||||
@@ -922,3 +936,5 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1115,11 +1115,11 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
|
||||
, dataAfterEnd_Error
|
||||
|
||||
_7Z_DECODER_CRYPRO_VARS
|
||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
||||
#if !defined(_7ZIP_ST)
|
||||
, false // mtMode
|
||||
, 1 // numThreads
|
||||
, 0 // memUsage
|
||||
#endif
|
||||
|
||||
);
|
||||
|
||||
RINOK(result);
|
||||
|
||||
@@ -1507,7 +1507,8 @@ void CThreadDecoder::Execute()
|
||||
|
||||
_7Z_DECODER_CRYPRO_VARS
|
||||
#ifndef _7ZIP_ST
|
||||
, MtMode, NumThreads
|
||||
, MtMode, NumThreads,
|
||||
0 // MemUsage
|
||||
#endif
|
||||
|
||||
);
|
||||
@@ -1696,13 +1697,14 @@ HRESULT Update(
|
||||
|
||||
UInt64 inSizeForReduce = 0;
|
||||
{
|
||||
bool isSolid = (numSolidFiles > 1 && options.NumSolidBytes != 0);
|
||||
FOR_VECTOR (i, updateItems)
|
||||
{
|
||||
const CUpdateItem &ui = updateItems[i];
|
||||
if (ui.NewData)
|
||||
{
|
||||
complexity += ui.Size;
|
||||
if (numSolidFiles != 1)
|
||||
if (isSolid)
|
||||
inSizeForReduce += ui.Size;
|
||||
else if (inSizeForReduce < ui.Size)
|
||||
inSizeForReduce = ui.Size;
|
||||
@@ -2142,8 +2144,8 @@ HRESULT Update(
|
||||
#ifndef _7ZIP_ST
|
||||
, false // mtMode
|
||||
, 1 // numThreads
|
||||
, 0 // memUsage
|
||||
#endif
|
||||
|
||||
);
|
||||
|
||||
RINOK(res);
|
||||
@@ -2293,7 +2295,8 @@ HRESULT Update(
|
||||
continue;
|
||||
CRecordVector<CRefItem> refItems;
|
||||
refItems.ClearAndSetSize(numFiles);
|
||||
bool sortByType = (options.UseTypeSorting && numSolidFiles > 1);
|
||||
// bool sortByType = (options.UseTypeSorting && isSoid); // numSolidFiles > 1
|
||||
bool sortByType = options.UseTypeSorting;
|
||||
|
||||
unsigned i;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user