mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 21:14:58 -06:00
18.03
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
|
||||
|
||||
@@ -714,8 +713,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++)
|
||||
@@ -734,13 +733,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;
|
||||
@@ -699,10 +703,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;
|
||||
@@ -722,6 +724,14 @@ void COutHandler::InitProps()
|
||||
_useTypeSorting = false;
|
||||
}
|
||||
|
||||
void COutHandler::InitProps()
|
||||
{
|
||||
CMultiMethodProps::Init();
|
||||
InitProps7z();
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT COutHandler::SetSolidFromString(const UString &s)
|
||||
{
|
||||
UString s2 = s;
|
||||
@@ -762,6 +772,10 @@ HRESULT COutHandler::SetSolidFromString(const UString &s)
|
||||
}
|
||||
_numSolidBytes = (v << numBits);
|
||||
_numSolidBytesDefined = true;
|
||||
/*
|
||||
if (_numSolidBytes == 0)
|
||||
_numSolidFiles = 1;
|
||||
*/
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
@@ -810,7 +824,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);
|
||||
@@ -921,3 +935,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;
|
||||
|
||||
|
||||
@@ -2,18 +2,92 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
#include "../../../Common/StringToInt.h"
|
||||
|
||||
#include "../Common/ParseProperties.h"
|
||||
|
||||
#include "HandlerOut.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
|
||||
bool ParseSizeString(const wchar_t *s, const PROPVARIANT &prop, UInt64 percentsBase, UInt64 &res)
|
||||
{
|
||||
if (*s == 0)
|
||||
{
|
||||
switch (prop.vt)
|
||||
{
|
||||
case VT_UI4: res = prop.ulVal; return true;
|
||||
case VT_UI8: res = prop.uhVal.QuadPart; return true;
|
||||
case VT_BSTR:
|
||||
s = prop.bstrVal;
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
else if (prop.vt != VT_EMPTY)
|
||||
return false;
|
||||
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(s, &end);
|
||||
if (s == end)
|
||||
return false;
|
||||
wchar_t c = *end;
|
||||
if (c == 0)
|
||||
{
|
||||
res = v;
|
||||
return true;
|
||||
}
|
||||
if (end[1] != 0)
|
||||
return false;
|
||||
|
||||
if (c == '%')
|
||||
{
|
||||
res = percentsBase / 100 * v;
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned numBits;
|
||||
switch (MyCharLower_Ascii(c))
|
||||
{
|
||||
case 'b': numBits = 0; break;
|
||||
case 'k': numBits = 10; break;
|
||||
case 'm': numBits = 20; break;
|
||||
case 'g': numBits = 30; break;
|
||||
case 't': numBits = 40; break;
|
||||
default: return false;
|
||||
}
|
||||
UInt64 val2 = v << numBits;
|
||||
if ((val2 >> numBits) != v)
|
||||
return false;
|
||||
res = val2;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCommonMethodProps::SetCommonProperty(const UString &name, const PROPVARIANT &value, HRESULT &hres)
|
||||
{
|
||||
hres = S_OK;
|
||||
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
hres = ParseMtProp(name.Ptr(2), value, _numProcessors, _numThreads);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("memuse"))
|
||||
{
|
||||
if (!ParseSizeString(name.Ptr(6), value, _memAvail, _memUsage))
|
||||
hres = E_INVALIDARG;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
|
||||
static void SetMethodProp32(COneMethodInfo &m, PROPID propID, UInt32 value)
|
||||
{
|
||||
if (m.FindProp(propID) < 0)
|
||||
@@ -34,21 +108,23 @@ void CMultiMethodProps::SetMethodThreadsTo(COneMethodInfo &oneMethodInfo, UInt32
|
||||
}
|
||||
#endif
|
||||
|
||||
void CMultiMethodProps::Init()
|
||||
void CMultiMethodProps::InitMulti()
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
_numProcessors = _numThreads = NSystem::GetNumberOfProcessors();
|
||||
#endif
|
||||
|
||||
_level = (UInt32)(Int32)-1;
|
||||
_analysisLevel = -1;
|
||||
|
||||
_autoFilter = true;
|
||||
_crcSize = 4;
|
||||
_filterMethod.Clear();
|
||||
_methods.Clear();
|
||||
_autoFilter = true;
|
||||
}
|
||||
|
||||
void CMultiMethodProps::Init()
|
||||
{
|
||||
InitCommon();
|
||||
InitMulti();
|
||||
_methods.Clear();
|
||||
_filterMethod.Clear();
|
||||
}
|
||||
|
||||
|
||||
HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value)
|
||||
{
|
||||
UString name = nameSpec;
|
||||
@@ -78,20 +154,18 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
|
||||
_crcSize = 4;
|
||||
return ParsePropToUInt32(name, value, _crcSize);
|
||||
}
|
||||
|
||||
{
|
||||
HRESULT hres;
|
||||
if (SetCommonProperty(name, value, hres))
|
||||
return hres;
|
||||
}
|
||||
|
||||
UInt32 number;
|
||||
unsigned index = ParseStringToUInt32(name, number);
|
||||
UString realName = name.Ptr(index);
|
||||
if (index == 0)
|
||||
{
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
RINOK(ParseMtProp(name.Ptr(2), value, _numProcessors, _numThreads));
|
||||
#endif
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
if (name.IsEqualTo("f"))
|
||||
{
|
||||
HRESULT res = PROPVARIANT_to_bool(value, _autoFilter);
|
||||
@@ -110,20 +184,20 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
|
||||
return _methods[number].ParseMethodFromPROPVARIANT(realName, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSingleMethodProps::Init()
|
||||
{
|
||||
InitCommon();
|
||||
InitSingle();
|
||||
Clear();
|
||||
_level = (UInt32)(Int32)-1;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
_numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors();
|
||||
AddProp_NumThreads(_numThreads);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
|
||||
{
|
||||
Init();
|
||||
|
||||
for (UInt32 i = 0; i < numProps; i++)
|
||||
{
|
||||
UString name = names[i];
|
||||
@@ -137,20 +211,22 @@ HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PR
|
||||
RINOK(ParsePropToUInt32(name.Ptr(1), value, a));
|
||||
_level = a;
|
||||
AddProp_Level(a);
|
||||
continue;
|
||||
}
|
||||
else if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
RINOK(ParseMtProp(name.Ptr(2), value, _numProcessors, _numThreads));
|
||||
AddProp_NumThreads(_numThreads);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(ParseMethodFromPROPVARIANT(names[i], value));
|
||||
HRESULT hres;
|
||||
if (SetCommonProperty(name, value, hres))
|
||||
{
|
||||
RINOK(hres)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
RINOK(ParseMethodFromPROPVARIANT(names[i], value));
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -3,20 +3,57 @@
|
||||
#ifndef __HANDLER_OUT_H
|
||||
#define __HANDLER_OUT_H
|
||||
|
||||
#include "../../../Windows/System.h"
|
||||
|
||||
#include "../../Common/MethodProps.h"
|
||||
|
||||
namespace NArchive {
|
||||
|
||||
class CMultiMethodProps
|
||||
bool ParseSizeString(const wchar_t *name, const PROPVARIANT &prop, UInt64 percentsBase, UInt64 &res);
|
||||
|
||||
class CCommonMethodProps
|
||||
{
|
||||
UInt32 _level;
|
||||
int _analysisLevel;
|
||||
protected:
|
||||
void InitCommon()
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
_numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors();
|
||||
#endif
|
||||
|
||||
UInt64 memAvail = (UInt64)(sizeof(size_t)) << 28;
|
||||
_memAvail = memAvail;
|
||||
_memUsage = memAvail;
|
||||
if (NWindows::NSystem::GetRamSize(memAvail))
|
||||
{
|
||||
_memAvail = memAvail;
|
||||
_memUsage = memAvail / 32 * 17;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
#ifndef _7ZIP_ST
|
||||
UInt32 _numThreads;
|
||||
UInt32 _numProcessors;
|
||||
#endif
|
||||
|
||||
UInt64 _memUsage;
|
||||
UInt64 _memAvail;
|
||||
|
||||
bool SetCommonProperty(const UString &name, const PROPVARIANT &value, HRESULT &hres);
|
||||
|
||||
CCommonMethodProps() { InitCommon(); }
|
||||
};
|
||||
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
|
||||
class CMultiMethodProps: public CCommonMethodProps
|
||||
{
|
||||
UInt32 _level;
|
||||
int _analysisLevel;
|
||||
|
||||
void InitMulti();
|
||||
public:
|
||||
UInt32 _crcSize;
|
||||
CObjectVector<COneMethodInfo> _methods;
|
||||
COneMethodInfo _filterMethod;
|
||||
@@ -43,27 +80,31 @@ public:
|
||||
int GetAnalysisLevel() const { return _analysisLevel; }
|
||||
|
||||
void Init();
|
||||
CMultiMethodProps() { InitMulti(); }
|
||||
|
||||
CMultiMethodProps() { Init(); }
|
||||
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
|
||||
};
|
||||
|
||||
class CSingleMethodProps: public COneMethodInfo
|
||||
|
||||
class CSingleMethodProps: public COneMethodInfo, public CCommonMethodProps
|
||||
{
|
||||
UInt32 _level;
|
||||
|
||||
public:
|
||||
#ifndef _7ZIP_ST
|
||||
UInt32 _numThreads;
|
||||
UInt32 _numProcessors;
|
||||
#endif
|
||||
|
||||
void InitSingle()
|
||||
{
|
||||
_level = (UInt32)(Int32)-1;
|
||||
}
|
||||
|
||||
public:
|
||||
void Init();
|
||||
CSingleMethodProps() { Init(); }
|
||||
CSingleMethodProps() { InitSingle(); }
|
||||
|
||||
int GetLevel() const { return _level == (UInt32)(Int32)-1 ? 5 : (int)_level; }
|
||||
HRESULT SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -488,6 +488,16 @@ ARCHIVE_INTERFACE(IOutArchive, 0xA0)
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
ISetProperties::SetProperties()
|
||||
PROPVARIANT values[i].vt:
|
||||
VT_EMPTY
|
||||
VT_BOOL
|
||||
VT_UI4 - if 32-bit number
|
||||
VT_UI8 - if 64-bit number
|
||||
VT_BSTR
|
||||
*/
|
||||
|
||||
ARCHIVE_INTERFACE(ISetProperties, 0x03)
|
||||
{
|
||||
STDMETHOD(SetProperties)(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps) PURE;
|
||||
|
||||
@@ -1086,7 +1086,7 @@ HRESULT CUnpacker::Create(DECL_EXTERNAL_CODECS_LOC_VARS const CItem &item, bool
|
||||
if (!lzCoder)
|
||||
{
|
||||
const UInt32 methodID = 0x40305;
|
||||
RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS methodID, false, lzCoder));
|
||||
RINOK(CreateCoder_Id(EXTERNAL_CODECS_LOC_VARS methodID, false, lzCoder));
|
||||
if (!lzCoder)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
@@ -1691,7 +1691,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
methodID += 2;
|
||||
else
|
||||
methodID += 3;
|
||||
RINOK(CreateCoder(EXTERNAL_CODECS_VARS methodID, false, mi.Coder));
|
||||
RINOK(CreateCoder_Id(EXTERNAL_CODECS_VARS methodID, false, mi.Coder));
|
||||
}
|
||||
|
||||
if (mi.Coder == 0)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../C/7zCrc.h"
|
||||
#include "../../../C/Alloc.h"
|
||||
#include "../../../C/CpuArch.h"
|
||||
#include "../../../C/Xz.h"
|
||||
@@ -1209,8 +1208,10 @@ HRESULT CHandler::Decompress(ISequentialOutStream *outStream, Byte *outBuf, bool
|
||||
else
|
||||
{
|
||||
ECoderStatus status;
|
||||
XzUnpacker_Init(&_xz);
|
||||
SRes res = XzUnpacker_Code(&_xz, dest, &destLen, _inputBuffer, &srcLen, CODER_FINISH_END, &status);
|
||||
SRes res = XzUnpacker_CodeFull(&_xz,
|
||||
dest, &destLen,
|
||||
_inputBuffer, &srcLen,
|
||||
CODER_FINISH_END, &status);
|
||||
if (res != 0)
|
||||
return SResToHRESULT(res);
|
||||
if (status != CODER_STATUS_NEEDS_MORE_INPUT || !XzUnpacker_IsStreamWasFinished(&_xz))
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
|
||||
#include "IArchive.h"
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
#include "Common/HandlerOut.h"
|
||||
#endif
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
@@ -49,14 +47,22 @@ class CHandler:
|
||||
public IInArchive,
|
||||
public IArchiveOpenSeq,
|
||||
public IInArchiveGetStream,
|
||||
public ISetProperties,
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
public IOutArchive,
|
||||
public ISetProperties,
|
||||
public CMultiMethodProps,
|
||||
#endif
|
||||
public CMyUnknownImp
|
||||
|
||||
public CMyUnknownImp,
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
public CMultiMethodProps
|
||||
#else
|
||||
public CCommonMethodProps
|
||||
#endif
|
||||
{
|
||||
NCompress::NXz::CStatInfo _stat;
|
||||
CXzStatInfo _stat;
|
||||
SRes MainDecodeSRes;
|
||||
|
||||
bool _isArc;
|
||||
bool _needSeekToStart;
|
||||
@@ -71,34 +77,48 @@ class CHandler:
|
||||
|
||||
UInt64 _numSolidBytes;
|
||||
|
||||
HRESULT SetSolidFromString(const UString &s);
|
||||
HRESULT SetSolidFromPROPVARIANT(const PROPVARIANT &value);
|
||||
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
|
||||
|
||||
void InitSolid()
|
||||
void InitXz()
|
||||
{
|
||||
_filterId = 0;
|
||||
_numSolidBytes = XZ_PROPS__BLOCK_SIZE__AUTO;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Init()
|
||||
{
|
||||
InitSolid();
|
||||
_filterId = 0;
|
||||
CMultiMethodProps::Init();
|
||||
#ifndef EXTRACT_ONLY
|
||||
InitXz();
|
||||
CMultiMethodProps::Init();
|
||||
#else
|
||||
CCommonMethodProps::InitCommon();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
|
||||
|
||||
HRESULT Open2(IInStream *inStream, /* UInt32 flags, */ IArchiveOpenCallback *callback);
|
||||
|
||||
HRESULT Decode2(ISequentialInStream *seqInStream, ISequentialOutStream *outStream,
|
||||
NCompress::NXz::CDecoder &decoder, ICompressProgressInfo *progress)
|
||||
HRESULT Decode(NCompress::NXz::CDecoder &decoder,
|
||||
ISequentialInStream *seqInStream,
|
||||
ISequentialOutStream *outStream,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
decoder._numThreads = _numThreads;
|
||||
#endif
|
||||
decoder._memUsage = _memUsage;
|
||||
|
||||
MainDecodeSRes = SZ_OK;
|
||||
|
||||
RINOK(decoder.Decode(seqInStream, outStream,
|
||||
NULL, // *outSizeLimit
|
||||
true, // finishStream
|
||||
progress));
|
||||
_stat = decoder;
|
||||
|
||||
_stat = decoder.Stat;
|
||||
MainDecodeSRes = decoder.MainDecodeSRes;
|
||||
|
||||
_phySize_Defined = true;
|
||||
return S_OK;
|
||||
}
|
||||
@@ -107,9 +127,9 @@ public:
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IArchiveOpenSeq)
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
#ifndef EXTRACT_ONLY
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
#endif
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
@@ -117,10 +137,10 @@ public:
|
||||
INTERFACE_IInArchive(;)
|
||||
STDMETHOD(OpenSeq)(ISequentialInStream *stream);
|
||||
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
|
||||
STDMETHOD(SetProperties)(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
INTERFACE_IOutArchive(;)
|
||||
STDMETHOD(SetProperties)(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
|
||||
#endif
|
||||
|
||||
size_t _blocksArraySize;
|
||||
@@ -146,7 +166,7 @@ CHandler::CHandler():
|
||||
_blocksArraySize(0)
|
||||
{
|
||||
#ifndef EXTRACT_ONLY
|
||||
Init();
|
||||
InitXz();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -307,7 +327,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
NCOM::CPropVariant prop;
|
||||
switch (propID)
|
||||
{
|
||||
case kpidPhySize: if (_phySize_Defined) prop = _stat.PhySize; break;
|
||||
case kpidPhySize: if (_phySize_Defined) prop = _stat.InSize; break;
|
||||
case kpidNumStreams: if (_stat.NumStreams_Defined) prop = _stat.NumStreams; break;
|
||||
case kpidNumBlocks: if (_stat.NumBlocks_Defined) prop = _stat.NumBlocks; break;
|
||||
case kpidUnpackSize: if (_stat.UnpackSize_Defined) prop = _stat.OutSize; break;
|
||||
@@ -330,19 +350,22 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
case kpidErrorFlags:
|
||||
{
|
||||
UInt32 v = 0;
|
||||
SRes sres = MainDecodeSRes; // _stat.DecodeRes2; //
|
||||
if (!_isArc) v |= kpv_ErrorFlags_IsNotArc;
|
||||
if (_stat.UnexpectedEnd) v |= kpv_ErrorFlags_UnexpectedEnd;
|
||||
if (/*_stat.UnexpectedEnd */ sres == SZ_ERROR_INPUT_EOF) v |= kpv_ErrorFlags_UnexpectedEnd;
|
||||
if (_stat.DataAfterEnd) v |= kpv_ErrorFlags_DataAfterEnd;
|
||||
if (_stat.HeadersError) v |= kpv_ErrorFlags_HeadersError;
|
||||
if (_stat.Unsupported) v |= kpv_ErrorFlags_UnsupportedMethod;
|
||||
if (_stat.DataError) v |= kpv_ErrorFlags_DataError;
|
||||
if (_stat.CrcError) v |= kpv_ErrorFlags_CrcError;
|
||||
prop = v;
|
||||
if (/* _stat.HeadersError */ sres == SZ_ERROR_ARCHIVE) v |= kpv_ErrorFlags_HeadersError;
|
||||
if (/* _stat.Unsupported */ sres == SZ_ERROR_UNSUPPORTED) v |= kpv_ErrorFlags_UnsupportedMethod;
|
||||
if (/* _stat.DataError */ sres == SZ_ERROR_DATA) v |= kpv_ErrorFlags_DataError;
|
||||
if (/* _stat.CrcError */ sres == SZ_ERROR_CRC) v |= kpv_ErrorFlags_CrcError;
|
||||
if (v != 0)
|
||||
prop = v;
|
||||
break;
|
||||
}
|
||||
|
||||
case kpidMainSubfile:
|
||||
{
|
||||
// debug only, comment it:
|
||||
// if (_blocks) prop = (UInt32)0;
|
||||
break;
|
||||
}
|
||||
@@ -365,7 +388,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32, PROPID propID, PROPVARIANT *value)
|
||||
switch (propID)
|
||||
{
|
||||
case kpidSize: if (_stat.UnpackSize_Defined) prop = _stat.OutSize; break;
|
||||
case kpidPackSize: if (_phySize_Defined) prop = _stat.PhySize; break;
|
||||
case kpidPackSize: if (_phySize_Defined) prop = _stat.InSize; break;
|
||||
case kpidMethod: if (!_methodsString.IsEmpty()) prop = _methodsString; break;
|
||||
}
|
||||
prop.Detach(value);
|
||||
@@ -483,10 +506,10 @@ HRESULT CHandler::Open2(IInStream *inStream, /* UInt32 flags, */ IArchiveOpenCal
|
||||
}
|
||||
}
|
||||
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_END, &_stat.PhySize));
|
||||
RINOK(inStream->Seek(0, STREAM_SEEK_END, &_stat.InSize));
|
||||
if (callback)
|
||||
{
|
||||
RINOK(callback->SetTotal(NULL, &_stat.PhySize));
|
||||
RINOK(callback->SetTotal(NULL, &_stat.InSize));
|
||||
}
|
||||
|
||||
CSeekInStreamWrap inStreamImp;
|
||||
@@ -621,7 +644,7 @@ STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream)
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_stat.Clear();
|
||||
XzStatInfo_Clear(&_stat);
|
||||
|
||||
_isArc = false;
|
||||
_needSeekToStart = false;
|
||||
@@ -637,6 +660,8 @@ STDMETHODIMP CHandler::Close()
|
||||
_blocksArraySize = 0;
|
||||
_maxBlocksSize = 0;
|
||||
|
||||
MainDecodeSRes = SZ_OK;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -743,6 +768,8 @@ static HRESULT DecodeBlock(CXzUnpackerCPP2 &xzu,
|
||||
xzu.p.streamFlags = (UInt16)streamFlags;
|
||||
XzUnpacker_PrepareToRandomBlockDecoding(&xzu.p);
|
||||
|
||||
XzUnpacker_SetOutBuf(&xzu.p, dest, unpackSize);
|
||||
|
||||
const UInt64 packSizeAligned = packSize + ((0 - (unsigned)packSize) & 3);
|
||||
UInt64 packRem = packSizeAligned;
|
||||
|
||||
@@ -771,8 +798,11 @@ static HRESULT DecodeBlock(CXzUnpackerCPP2 &xzu,
|
||||
ECoderStatus status;
|
||||
|
||||
SRes res = XzUnpacker_Code(&xzu.p,
|
||||
dest + outPos, &outLen,
|
||||
// dest + outPos,
|
||||
NULL,
|
||||
&outLen,
|
||||
xzu.InBuf + inPos, &inLen,
|
||||
(inLen == 0), // srcFinished
|
||||
CODER_FINISH_END, &status);
|
||||
|
||||
// return E_OUTOFMEMORY;
|
||||
@@ -890,15 +920,16 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (!_stat.UnpackSize_Defined
|
||||
|| _maxBlocksSize == 0 // 18.02
|
||||
|| _maxBlocksSize > kMaxBlockSize_for_GetStream
|
||||
|| _maxBlocksSize != (size_t)_maxBlocksSize)
|
||||
return S_FALSE;
|
||||
|
||||
UInt64 physSize = (UInt64)(sizeof(size_t)) << 29;
|
||||
bool ramSize_Defined = NSystem::GetRamSize(physSize);
|
||||
if (ramSize_Defined)
|
||||
UInt64 memSize;
|
||||
if (!NSystem::GetRamSize(memSize))
|
||||
memSize = (UInt64)(sizeof(size_t)) << 28;
|
||||
{
|
||||
if (_maxBlocksSize > physSize / 4)
|
||||
if (_maxBlocksSize > memSize / 4)
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
@@ -917,6 +948,31 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
}
|
||||
|
||||
|
||||
static Int32 Get_Extract_OperationResult(const NCompress::NXz::CDecoder &decoder)
|
||||
{
|
||||
Int32 opRes;
|
||||
SRes sres = decoder.MainDecodeSRes; // decoder.Stat.DecodeRes2;
|
||||
if (sres == SZ_ERROR_NO_ARCHIVE) // (!IsArc)
|
||||
opRes = NExtract::NOperationResult::kIsNotArc;
|
||||
else if (sres == SZ_ERROR_INPUT_EOF) // (UnexpectedEnd)
|
||||
opRes = NExtract::NOperationResult::kUnexpectedEnd;
|
||||
else if (decoder.Stat.DataAfterEnd)
|
||||
opRes = NExtract::NOperationResult::kDataAfterEnd;
|
||||
else if (sres == SZ_ERROR_CRC) // (CrcError)
|
||||
opRes = NExtract::NOperationResult::kCRCError;
|
||||
else if (sres == SZ_ERROR_UNSUPPORTED) // (Unsupported)
|
||||
opRes = NExtract::NOperationResult::kUnsupportedMethod;
|
||||
else if (sres == SZ_ERROR_ARCHIVE) // (HeadersError)
|
||||
opRes = NExtract::NOperationResult::kDataError;
|
||||
else if (sres == SZ_ERROR_DATA) // (DataError)
|
||||
opRes = NExtract::NOperationResult::kDataError;
|
||||
else if (sres != SZ_OK)
|
||||
opRes = NExtract::NOperationResult::kDataError;
|
||||
else
|
||||
opRes = NExtract::NOperationResult::kOK;
|
||||
return opRes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -930,7 +986,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (_phySize_Defined)
|
||||
extractCallback->SetTotal(_stat.PhySize);
|
||||
extractCallback->SetTotal(_stat.InSize);
|
||||
|
||||
UInt64 currentTotalPacked = 0;
|
||||
RINOK(extractCallback->SetCompleted(¤tTotalPacked));
|
||||
@@ -959,9 +1015,18 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
else
|
||||
_needSeekToStart = true;
|
||||
|
||||
|
||||
NCompress::NXz::CDecoder decoder;
|
||||
RINOK(Decode2(_seqStream, realOutStream, decoder, lpsRef));
|
||||
Int32 opRes = decoder.Get_Extract_OperationResult();
|
||||
|
||||
HRESULT hres = Decode(decoder, _seqStream, realOutStream, lpsRef);
|
||||
|
||||
if (!decoder.MainDecodeSRes_wasUsed)
|
||||
return hres == S_OK ? E_FAIL : hres;
|
||||
|
||||
Int32 opRes = Get_Extract_OperationResult(decoder);
|
||||
if (opRes == NExtract::NOperationResult::kOK
|
||||
&& hres != S_OK)
|
||||
opRes = NExtract::NOperationResult::kDataError;
|
||||
|
||||
realOutStream.Release();
|
||||
return extractCallback->SetOperationResult(opRes);
|
||||
@@ -1112,7 +1177,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
if (_stream)
|
||||
{
|
||||
if (_phySize_Defined)
|
||||
RINOK(updateCallback->SetTotal(_stat.PhySize));
|
||||
RINOK(updateCallback->SetTotal(_stat.InSize));
|
||||
RINOK(_stream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
}
|
||||
|
||||
@@ -1125,55 +1190,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
HRESULT CHandler::SetSolidFromString(const UString &s)
|
||||
{
|
||||
UString s2 = s;
|
||||
s2.MakeLower_Ascii();
|
||||
|
||||
{
|
||||
const wchar_t *start = ((const wchar_t *)s2);
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(start, &end);
|
||||
if (start == end)
|
||||
return E_INVALIDARG;
|
||||
if ((unsigned)(end - start) + 1 != s2.Len())
|
||||
return E_INVALIDARG;
|
||||
wchar_t c = *end;
|
||||
{
|
||||
unsigned numBits;
|
||||
switch (c)
|
||||
{
|
||||
case 'b': numBits = 0; break;
|
||||
case 'k': numBits = 10; break;
|
||||
case 'm': numBits = 20; break;
|
||||
case 'g': numBits = 30; break;
|
||||
case 't': numBits = 40; break;
|
||||
default: return E_INVALIDARG;
|
||||
}
|
||||
_numSolidBytes = (v << numBits);
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CHandler::SetSolidFromPROPVARIANT(const PROPVARIANT &value)
|
||||
{
|
||||
bool isSolid;
|
||||
switch (value.vt)
|
||||
{
|
||||
case VT_EMPTY: isSolid = true; break;
|
||||
case VT_BOOL: isSolid = (value.boolVal != VARIANT_FALSE); break;
|
||||
case VT_BSTR:
|
||||
if (StringToBool(value.bstrVal, isSolid))
|
||||
break;
|
||||
return SetSolidFromString(value.bstrVal);
|
||||
default: return E_INVALIDARG;
|
||||
}
|
||||
_numSolidBytes = (isSolid ? XZ_PROPS__BLOCK_SIZE__SOLID : XZ_PROPS__BLOCK_SIZE__AUTO);
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
HRESULT CHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value)
|
||||
@@ -1183,20 +1200,53 @@ HRESULT CHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value)
|
||||
if (name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
|
||||
if (name[0] == L's')
|
||||
{
|
||||
name.Delete(0);
|
||||
if (name.IsEmpty())
|
||||
return SetSolidFromPROPVARIANT(value);
|
||||
if (value.vt != VT_EMPTY)
|
||||
return E_INVALIDARG;
|
||||
return SetSolidFromString(name);
|
||||
const wchar_t *s = name.Ptr(1);
|
||||
if (*s == 0)
|
||||
{
|
||||
bool useStr = false;
|
||||
bool isSolid;
|
||||
switch (value.vt)
|
||||
{
|
||||
case VT_EMPTY: isSolid = true; break;
|
||||
case VT_BOOL: isSolid = (value.boolVal != VARIANT_FALSE); break;
|
||||
case VT_BSTR:
|
||||
if (!StringToBool(value.bstrVal, isSolid))
|
||||
useStr = true;
|
||||
break;
|
||||
default: return E_INVALIDARG;
|
||||
}
|
||||
if (!useStr)
|
||||
{
|
||||
_numSolidBytes = (isSolid ? XZ_PROPS__BLOCK_SIZE__SOLID : XZ_PROPS__BLOCK_SIZE__AUTO);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
return ParseSizeString(s, value,
|
||||
0, // percentsBase
|
||||
_numSolidBytes) ? S_OK: E_INVALIDARG;
|
||||
}
|
||||
|
||||
|
||||
return CMultiMethodProps::SetProperty(name, value);
|
||||
|
||||
#else
|
||||
|
||||
{
|
||||
HRESULT hres;
|
||||
if (SetCommonProperty(name, value, hres))
|
||||
return hres;
|
||||
}
|
||||
|
||||
return E_INVALIDARG;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
@@ -1208,6 +1258,8 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
||||
RINOK(SetProperty(names[i], values[i]));
|
||||
}
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
|
||||
if (!_filterMethod.MethodName.IsEmpty())
|
||||
{
|
||||
unsigned k;
|
||||
@@ -1238,12 +1290,13 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return S_OK;
|
||||
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
REGISTER_ARC_IO(
|
||||
"xz", "xz txz", "* .tar", 0xC,
|
||||
|
||||
@@ -384,7 +384,7 @@ HRESULT CAddCommon::Compress(
|
||||
methodId = kMethodId_ZipBase + method;
|
||||
break;
|
||||
}
|
||||
RINOK(CreateCoder(
|
||||
RINOK(CreateCoder_Id(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
methodId, true, _compressEncoder));
|
||||
if (!_compressEncoder)
|
||||
|
||||
@@ -112,7 +112,8 @@ static const CUInt32PCharPair g_HeaderCharacts[] =
|
||||
{ 3, "Descriptor" },
|
||||
// { 5, "Patched" },
|
||||
{ 6, kMethod_StrongCrypto },
|
||||
{ 11, "UTF8" }
|
||||
{ 11, "UTF8" },
|
||||
{ 14, "Alt" }
|
||||
};
|
||||
|
||||
struct CIdToNamePair
|
||||
@@ -169,6 +170,7 @@ static const Byte kProps[] =
|
||||
kpidUnpackVer,
|
||||
kpidVolumeIndex,
|
||||
kpidOffset
|
||||
// kpidIsAltStream
|
||||
};
|
||||
|
||||
static const Byte kArcProps[] =
|
||||
@@ -307,6 +309,8 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
prop = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// case kpidIsAltStream: prop = true; break;
|
||||
}
|
||||
prop.Detach(value);
|
||||
COM_TRY_END
|
||||
@@ -333,6 +337,21 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
UString res;
|
||||
item.GetUnicodeString(res, item.Name, false, _forceCodePage, _specifiedCodePage);
|
||||
NItemName::ReplaceToOsSlashes_Remove_TailSlash(res);
|
||||
/*
|
||||
if (item.ParentOfAltStream >= 0)
|
||||
{
|
||||
const CItemEx &prevItem = m_Items[item.ParentOfAltStream];
|
||||
UString prevName;
|
||||
prevItem.GetUnicodeString(prevName, prevItem.Name, false, _forceCodePage, _specifiedCodePage);
|
||||
NItemName::ReplaceToOsSlashes_Remove_TailSlash(prevName);
|
||||
if (res.IsPrefixedBy(prevName))
|
||||
if (IsString1PrefixedByString2(res.Ptr(prevName.Len()), k_SpecName_NTFS_STREAM))
|
||||
{
|
||||
res.Delete(prevName.Len(), (unsigned)strlen(k_SpecName_NTFS_STREAM));
|
||||
res.Insert(prevName.Len(), L":");
|
||||
}
|
||||
}
|
||||
*/
|
||||
prop = res;
|
||||
break;
|
||||
}
|
||||
@@ -596,6 +615,19 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
case kpidOffset:
|
||||
prop = item.LocalHeaderPos;
|
||||
break;
|
||||
|
||||
/*
|
||||
case kpidIsAltStream:
|
||||
prop = (bool)(item.ParentOfAltStream >= 0); // item.IsAltStream();
|
||||
break;
|
||||
|
||||
case kpidName:
|
||||
if (item.ParentOfAltStream >= 0)
|
||||
{
|
||||
// extract name of stream here
|
||||
}
|
||||
break;
|
||||
*/
|
||||
}
|
||||
|
||||
prop.Detach(value);
|
||||
@@ -604,6 +636,85 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
STDMETHODIMP CHandler::GetNumRawProps(UInt32 *numProps)
|
||||
{
|
||||
*numProps = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID)
|
||||
{
|
||||
UNUSED_VAR(index);
|
||||
*propID = 0;
|
||||
*name = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentType)
|
||||
{
|
||||
*parentType = NParentType::kDir;
|
||||
*parent = (UInt32)(Int32)-1;
|
||||
if (index >= m_Items.Size())
|
||||
return S_OK;
|
||||
const CItemEx &item = m_Items[index];
|
||||
|
||||
if (item.ParentOfAltStream >= 0)
|
||||
{
|
||||
*parentType = NParentType::kAltStream;
|
||||
*parent = item.ParentOfAltStream;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType)
|
||||
{
|
||||
UNUSED_VAR(index);
|
||||
UNUSED_VAR(propID);
|
||||
*data = NULL;
|
||||
*dataSize = 0;
|
||||
*propType = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
void CHandler::MarkAltStreams(CObjectVector<CItemEx> &items)
|
||||
{
|
||||
int prevIndex = -1;
|
||||
UString prevName;
|
||||
UString name;
|
||||
|
||||
for (unsigned i = 0; i < items.Size(); i++)
|
||||
{
|
||||
CItemEx &item = m_Items[i];
|
||||
if (item.IsAltStream())
|
||||
{
|
||||
if (prevIndex == -1)
|
||||
continue;
|
||||
if (prevName.IsEmpty())
|
||||
{
|
||||
const CItemEx &prevItem = m_Items[prevIndex];
|
||||
prevItem.GetUnicodeString(prevName, prevItem.Name, false, _forceCodePage, _specifiedCodePage);
|
||||
NItemName::ReplaceToOsSlashes_Remove_TailSlash(prevName);
|
||||
}
|
||||
name.Empty();
|
||||
item.GetUnicodeString(name, item.Name, false, _forceCodePage, _specifiedCodePage);
|
||||
NItemName::ReplaceToOsSlashes_Remove_TailSlash(name);
|
||||
|
||||
if (name.IsPrefixedBy(prevName))
|
||||
if (IsString1PrefixedByString2(name.Ptr(prevName.Len()), k_SpecName_NTFS_STREAM))
|
||||
item.ParentOfAltStream = prevIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
prevIndex = i;
|
||||
prevName.Empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *callback)
|
||||
{
|
||||
@@ -617,6 +728,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
m_Items.Clear();
|
||||
m_Archive.ClearRefs(); // we don't want to clear error flags
|
||||
}
|
||||
// MarkAltStreams(m_Items);
|
||||
return res;
|
||||
}
|
||||
catch(...) { Close(); throw; }
|
||||
@@ -738,7 +850,7 @@ public:
|
||||
IArchiveExtractCallback *extractCallback,
|
||||
ICompressProgressInfo *compressProgress,
|
||||
#ifndef _7ZIP_ST
|
||||
UInt32 numThreads,
|
||||
UInt32 numThreads, UInt64 memUsage,
|
||||
#endif
|
||||
Int32 &res);
|
||||
};
|
||||
@@ -767,7 +879,7 @@ HRESULT CZipDecoder::Decode(
|
||||
IArchiveExtractCallback *extractCallback,
|
||||
ICompressProgressInfo *compressProgress,
|
||||
#ifndef _7ZIP_ST
|
||||
UInt32 numThreads,
|
||||
UInt32 numThreads, UInt64 memUsage,
|
||||
#endif
|
||||
Int32 &res)
|
||||
{
|
||||
@@ -962,7 +1074,7 @@ HRESULT CZipDecoder::Decode(
|
||||
szMethodID = kMethodId_ZipBase + (Byte)id;
|
||||
}
|
||||
|
||||
RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS szMethodID, false, mi.Coder));
|
||||
RINOK(CreateCoder_Id(EXTERNAL_CODECS_LOC_VARS szMethodID, false, mi.Coder));
|
||||
|
||||
if (!mi.Coder)
|
||||
{
|
||||
@@ -974,16 +1086,7 @@ HRESULT CZipDecoder::Decode(
|
||||
}
|
||||
|
||||
ICompressCoder *coder = methodItems[m].Coder;
|
||||
|
||||
{
|
||||
CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
|
||||
coder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
|
||||
if (setDecoderProperties)
|
||||
{
|
||||
Byte properties = (Byte)item.Flags;
|
||||
RINOK(setDecoderProperties->SetDecoderProperties2(&properties, 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
{
|
||||
@@ -994,7 +1097,27 @@ HRESULT CZipDecoder::Decode(
|
||||
RINOK(setCoderMt->SetNumberOfThreads(numThreads));
|
||||
}
|
||||
}
|
||||
// if (memUsage != 0)
|
||||
{
|
||||
CMyComPtr<ICompressSetMemLimit> setMemLimit;
|
||||
coder->QueryInterface(IID_ICompressSetMemLimit, (void **)&setMemLimit);
|
||||
if (setMemLimit)
|
||||
{
|
||||
RINOK(setMemLimit->SetMemLimit(memUsage));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
|
||||
coder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
|
||||
if (setDecoderProperties)
|
||||
{
|
||||
Byte properties = (Byte)item.Flags;
|
||||
RINOK(setDecoderProperties->SetDecoderProperties2(&properties, 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CMyComPtr<ISequentialInStream> inStreamNew;
|
||||
|
||||
@@ -1319,7 +1442,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
m_Archive, item, realOutStream, extractCallback,
|
||||
progress,
|
||||
#ifndef _7ZIP_ST
|
||||
_props._numThreads,
|
||||
_props._numThreads, _props._memUsage,
|
||||
#endif
|
||||
res);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ extern const char * const kMethodNames2[kNumMethodNames2];
|
||||
|
||||
class CHandler:
|
||||
public IInArchive,
|
||||
// public IArchiveGetRawProps,
|
||||
public IOutArchive,
|
||||
public ISetProperties,
|
||||
PUBLIC_ISetCompressCodecsInfo
|
||||
@@ -32,6 +33,7 @@ class CHandler:
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
// MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps)
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
@@ -39,6 +41,7 @@ public:
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
INTERFACE_IInArchive(;)
|
||||
// INTERFACE_IArchiveGetRawProps(;)
|
||||
INTERFACE_IOutArchive(;)
|
||||
|
||||
STDMETHOD(SetProperties)(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
|
||||
@@ -75,6 +78,10 @@ private:
|
||||
_forceCodePage = false;
|
||||
_specifiedCodePage = CP_OEMCP;
|
||||
}
|
||||
|
||||
// void MarkAltStreams(CObjectVector<CItemEx> &items);
|
||||
|
||||
HRESULT GetOutProperty(IArchiveUpdateCallback *callback, UInt32 callbackIndex, Int32 arcIndex, PROPID propID, PROPVARIANT *value);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -376,7 +376,8 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
{
|
||||
CMethodId methodId;
|
||||
UInt32 numStreams;
|
||||
if (!FindMethod(EXTERNAL_CODECS_VARS methodName, methodId, numStreams))
|
||||
if (FindMethod_Index(EXTERNAL_CODECS_VARS methodName, true,
|
||||
methodId, numStreams) < 0)
|
||||
return E_NOTIMPL;
|
||||
if (numStreams != 1)
|
||||
return E_NOTIMPL;
|
||||
|
||||
@@ -2632,6 +2632,34 @@ SOURCE=..\..\..\..\C\Lzma2Dec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.c
|
||||
|
||||
!IF "$(CFG)" == "Alone - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2Enc.c
|
||||
|
||||
!IF "$(CFG)" == "Alone - Win32 Release"
|
||||
@@ -2744,6 +2772,34 @@ SOURCE=..\..\..\..\C\MtCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.c
|
||||
|
||||
!IF "$(CFG)" == "Alone - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Ppmd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -198,10 +198,12 @@ C_OBJS = \
|
||||
$O\LzFind.obj \
|
||||
$O\LzFindMt.obj \
|
||||
$O\Lzma2Dec.obj \
|
||||
$O\Lzma2DecMt.obj \
|
||||
$O\Lzma2Enc.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\LzmaEnc.obj \
|
||||
$O\MtCoder.obj \
|
||||
$O\MtDec.obj \
|
||||
$O\Ppmd7.obj \
|
||||
$O\Ppmd7Dec.obj \
|
||||
$O\Ppmd7Enc.obj \
|
||||
@@ -222,5 +224,6 @@ C_OBJS = \
|
||||
!include "../../Aes.mak"
|
||||
!include "../../Crc.mak"
|
||||
!include "../../Crc64.mak"
|
||||
!include "../../LzmaDec.mak"
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -1696,6 +1696,34 @@ SOURCE=..\..\..\..\C\Lzma2Dec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.c
|
||||
|
||||
!IF "$(CFG)" == "Alone - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2Enc.c
|
||||
|
||||
!IF "$(CFG)" == "Alone - Win32 Release"
|
||||
@@ -1789,6 +1817,34 @@ SOURCE=..\..\..\..\C\MtCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.c
|
||||
|
||||
!IF "$(CFG)" == "Alone - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
@@ -133,10 +133,12 @@ C_OBJS = \
|
||||
$O\LzFind.obj \
|
||||
$O\LzFindMt.obj \
|
||||
$O\Lzma2Dec.obj \
|
||||
$O\Lzma2DecMt.obj \
|
||||
$O\Lzma2Enc.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\LzmaEnc.obj \
|
||||
$O\MtCoder.obj \
|
||||
$O\MtDec.obj \
|
||||
$O\Sha256.obj \
|
||||
$O\Sort.obj \
|
||||
$O\Threads.obj \
|
||||
@@ -150,5 +152,6 @@ C_OBJS = \
|
||||
!include "../../Aes.mak"
|
||||
!include "../../Crc.mak"
|
||||
!include "../../Crc64.mak"
|
||||
!include "../../LzmaDec.mak"
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -1004,6 +1004,15 @@ SOURCE=..\..\..\..\C\Lzma2Dec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2Enc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
@@ -1040,6 +1049,15 @@ SOURCE=..\..\..\..\C\MtCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sha256.c
|
||||
|
||||
!IF "$(CFG)" == "FM - Win32 Release"
|
||||
|
||||
@@ -123,10 +123,12 @@ C_OBJS = \
|
||||
$O\LzFind.obj \
|
||||
$O\LzFindMt.obj \
|
||||
$O\Lzma2Dec.obj \
|
||||
$O\Lzma2DecMt.obj \
|
||||
$O\Lzma2Enc.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\LzmaEnc.obj \
|
||||
$O\MtCoder.obj \
|
||||
$O\MtDec.obj \
|
||||
$O\Ppmd7.obj \
|
||||
$O\Ppmd7Dec.obj \
|
||||
$O\Ppmd7Enc.obj \
|
||||
@@ -136,5 +138,6 @@ C_OBJS = \
|
||||
|
||||
!include "../../Aes.mak"
|
||||
!include "../../Crc.mak"
|
||||
!include "../../LzmaDec.mak"
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -42,6 +42,7 @@ AR_OBJS = \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\HandlerOut.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
@@ -98,7 +99,9 @@ C_OBJS = \
|
||||
$O\CpuArch.obj \
|
||||
$O\Delta.obj \
|
||||
$O\Lzma2Dec.obj \
|
||||
$O\Lzma2DecMt.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\MtDec.obj \
|
||||
$O\Ppmd7.obj \
|
||||
$O\Ppmd7Dec.obj \
|
||||
$O\Sha256.obj \
|
||||
@@ -106,5 +109,6 @@ C_OBJS = \
|
||||
|
||||
!include "../../Aes.mak"
|
||||
!include "../../Crc.mak"
|
||||
!include "../../LzmaDec.mak"
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -85,9 +85,12 @@ C_OBJS = \
|
||||
$O\CpuArch.obj \
|
||||
$O\Delta.obj \
|
||||
$O\Lzma2Dec.obj \
|
||||
$O\Lzma2DecMt.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\MtDec.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
!include "../../Crc.mak"
|
||||
!include "../../LzmaDec.mak"
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -263,10 +263,12 @@ C_OBJS = \
|
||||
$O\LzFind.obj \
|
||||
$O\LzFindMt.obj \
|
||||
$O\Lzma2Dec.obj \
|
||||
$O\Lzma2DecMt.obj \
|
||||
$O\Lzma2Enc.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\LzmaEnc.obj \
|
||||
$O\MtCoder.obj \
|
||||
$O\MtDec.obj \
|
||||
$O\Ppmd7.obj \
|
||||
$O\Ppmd7Dec.obj \
|
||||
$O\Ppmd7Enc.obj \
|
||||
@@ -285,3 +287,4 @@ C_OBJS = \
|
||||
!include "../../Aes.mak"
|
||||
!include "../../Crc.mak"
|
||||
!include "../../Crc64.mak"
|
||||
!include "../../LzmaDec.mak"
|
||||
|
||||
@@ -1805,6 +1805,26 @@ SOURCE=..\..\..\..\C\Lzma2Dec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.c
|
||||
|
||||
!IF "$(CFG)" == "7z - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "7z - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2Enc.c
|
||||
|
||||
!IF "$(CFG)" == "7z - Win32 Release"
|
||||
@@ -1874,6 +1894,26 @@ SOURCE=..\..\..\..\C\MtCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.c
|
||||
|
||||
!IF "$(CFG)" == "7z - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "7z - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Ppmd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -102,12 +102,15 @@ C_OBJS = \
|
||||
$O\LzFind.obj \
|
||||
$O\LzFindMt.obj \
|
||||
$O\Lzma2Dec.obj \
|
||||
$O\Lzma2DecMt.obj \
|
||||
$O\Lzma2Enc.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\LzmaEnc.obj \
|
||||
$O\MtCoder.obj \
|
||||
$O\MtDec.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
!include "../../Crc.mak"
|
||||
!include "../../LzmaDec.mak"
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -117,6 +117,14 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\HandlerOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\HandlerOut.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -293,6 +301,10 @@ SOURCE=..\..\Compress\Lzma2Decoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzma2Decoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzma2Register.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -411,6 +423,14 @@ SOURCE=..\..\..\Windows\Synchronization.cpp
|
||||
|
||||
SOURCE=..\..\..\Windows\Synchronization.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\System.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\System.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
@@ -822,6 +842,15 @@ SOURCE=..\..\..\..\C\Lzma2Dec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzmaDec.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
@@ -831,6 +860,15 @@ SOURCE=..\..\..\..\C\LzmaDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Ppmd7.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
@@ -41,6 +41,7 @@ WIN_OBJS = \
|
||||
$O\PropVariant.obj \
|
||||
$O\PropVariantConv.obj \
|
||||
$O\Synchronization.obj \
|
||||
$O\System.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\CreateCoder.obj \
|
||||
@@ -117,7 +118,9 @@ C_OBJS = \
|
||||
$O\Delta.obj \
|
||||
$O\DllSecur.obj \
|
||||
$O\Lzma2Dec.obj \
|
||||
$O\Lzma2DecMt.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\MtDec.obj \
|
||||
$O\Ppmd7.obj \
|
||||
$O\Ppmd7Dec.obj \
|
||||
$O\Sha256.obj \
|
||||
@@ -125,5 +128,6 @@ C_OBJS = \
|
||||
|
||||
!include "../../Aes.mak"
|
||||
!include "../../Crc.mak"
|
||||
!include "../../LzmaDec.mak"
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -449,6 +449,14 @@ SOURCE=..\..\..\Windows\Synchronization.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\System.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\System.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Window.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -469,6 +477,14 @@ SOURCE=..\..\Common\CreateCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CWrappers.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CWrappers.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FileStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -724,6 +740,15 @@ SOURCE=..\..\..\..\C\Lzma2Dec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzmaDec.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
@@ -733,6 +758,15 @@ SOURCE=..\..\..\..\C\LzmaDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
@@ -33,6 +33,7 @@ WIN_OBJS = \
|
||||
$O\PropVariant.obj \
|
||||
$O\ResourceString.obj \
|
||||
$O\Synchronization.obj \
|
||||
$O\System.obj \
|
||||
$O\Window.obj \
|
||||
|
||||
WIN_CTRL_OBJS = \
|
||||
@@ -40,6 +41,7 @@ WIN_CTRL_OBJS = \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\CreateCoder.obj \
|
||||
$O\CWrappers.obj \
|
||||
$O\FileStreams.obj \
|
||||
$O\InBuffer.obj \
|
||||
$O\FilterCoder.obj \
|
||||
@@ -102,9 +104,12 @@ C_OBJS = \
|
||||
$O\Delta.obj \
|
||||
$O\DllSecur.obj \
|
||||
$O\Lzma2Dec.obj \
|
||||
$O\Lzma2DecMt.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\MtDec.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
!include "../../Crc.mak"
|
||||
!include "../../LzmaDec.mak"
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -633,6 +633,14 @@ SOURCE=..\..\..\Windows\Synchronization.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\System.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\System.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Window.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -906,6 +914,15 @@ SOURCE=..\..\..\..\C\Lzma2Dec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma2DecMt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzmaDec.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
@@ -915,6 +932,15 @@ SOURCE=..\..\..\..\C\LzmaDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\MtDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Ppmd7.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
@@ -41,6 +41,7 @@ WIN_OBJS = \
|
||||
$O\ResourceString.obj \
|
||||
$O\Shell.obj \
|
||||
$O\Synchronization.obj \
|
||||
$O\System.obj \
|
||||
$O\Window.obj \
|
||||
|
||||
WIN_CTRL_OBJS = \
|
||||
@@ -135,7 +136,9 @@ C_OBJS = \
|
||||
$O\Delta.obj \
|
||||
$O\DllSecur.obj \
|
||||
$O\Lzma2Dec.obj \
|
||||
$O\Lzma2DecMt.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\MtDec.obj \
|
||||
$O\Ppmd7.obj \
|
||||
$O\Ppmd7Dec.obj \
|
||||
$O\Sha256.obj \
|
||||
@@ -143,5 +146,6 @@ C_OBJS = \
|
||||
|
||||
!include "../../Aes.mak"
|
||||
!include "../../Crc.mak"
|
||||
!include "../../LzmaDec.mak"
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -148,20 +148,23 @@ HRESULT CExternalCodecs::Load()
|
||||
#endif
|
||||
|
||||
|
||||
bool FindMethod(
|
||||
int FindMethod_Index(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const AString &name,
|
||||
CMethodId &methodId, UInt32 &numStreams)
|
||||
bool encode,
|
||||
CMethodId &methodId,
|
||||
UInt32 &numStreams)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < g_NumCodecs; i++)
|
||||
{
|
||||
const CCodecInfo &codec = *g_Codecs[i];
|
||||
if (StringsAreEqualNoCase_Ascii(name, codec.Name))
|
||||
if ((encode ? codec.CreateEncoder : codec.CreateDecoder)
|
||||
&& StringsAreEqualNoCase_Ascii(name, codec.Name))
|
||||
{
|
||||
methodId = codec.Id;
|
||||
numStreams = codec.NumStreams;
|
||||
return true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,19 +176,51 @@ bool FindMethod(
|
||||
for (i = 0; i < __externalCodecs->Codecs.Size(); i++)
|
||||
{
|
||||
const CCodecInfoEx &codec = __externalCodecs->Codecs[i];
|
||||
if (StringsAreEqualNoCase_Ascii(name, codec.Name))
|
||||
if ((encode ? codec.EncoderIsAssigned : codec.DecoderIsAssigned)
|
||||
&& StringsAreEqualNoCase_Ascii(name, codec.Name))
|
||||
{
|
||||
methodId = codec.Id;
|
||||
numStreams = codec.NumStreams;
|
||||
return true;
|
||||
return g_NumCodecs + i;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static int FindMethod_Index(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CMethodId methodId, bool encode)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < g_NumCodecs; i++)
|
||||
{
|
||||
const CCodecInfo &codec = *g_Codecs[i];
|
||||
if (codec.Id == methodId && (encode ? codec.CreateEncoder : codec.CreateDecoder))
|
||||
return i;
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
|
||||
CHECK_GLOBAL_CODECS
|
||||
|
||||
if (__externalCodecs)
|
||||
for (i = 0; i < __externalCodecs->Codecs.Size(); i++)
|
||||
{
|
||||
const CCodecInfoEx &codec = __externalCodecs->Codecs[i];
|
||||
if (codec.Id == methodId && (encode ? codec.EncoderIsAssigned : codec.DecoderIsAssigned))
|
||||
return g_NumCodecs + i;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
bool FindMethod(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CMethodId methodId,
|
||||
@@ -280,9 +315,11 @@ void GetHashMethods(
|
||||
#endif
|
||||
}
|
||||
|
||||
HRESULT CreateCoder(
|
||||
|
||||
|
||||
HRESULT CreateCoder_Index(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CMethodId methodId, bool encode,
|
||||
unsigned i, bool encode,
|
||||
CMyComPtr<ICompressFilter> &filter,
|
||||
CCreatedCoder &cod)
|
||||
{
|
||||
@@ -290,11 +327,10 @@ HRESULT CreateCoder(
|
||||
cod.IsFilter = false;
|
||||
cod.NumStreams = 1;
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < g_NumCodecs; i++)
|
||||
if (i < g_NumCodecs)
|
||||
{
|
||||
const CCodecInfo &codec = *g_Codecs[i];
|
||||
if (codec.Id == methodId)
|
||||
// if (codec.Id == methodId)
|
||||
{
|
||||
if (encode)
|
||||
{
|
||||
@@ -325,11 +361,12 @@ HRESULT CreateCoder(
|
||||
|
||||
if (__externalCodecs)
|
||||
{
|
||||
i -= g_NumCodecs;
|
||||
cod.IsExternal = true;
|
||||
for (i = 0; i < __externalCodecs->Codecs.Size(); i++)
|
||||
if (i < __externalCodecs->Codecs.Size())
|
||||
{
|
||||
const CCodecInfoEx &codec = __externalCodecs->Codecs[i];
|
||||
if (codec.Id == methodId)
|
||||
// if (codec.Id == methodId)
|
||||
{
|
||||
if (encode)
|
||||
{
|
||||
@@ -371,13 +408,50 @@ HRESULT CreateCoder(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CreateCoder(
|
||||
|
||||
HRESULT CreateCoder_Index(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
unsigned index, bool encode,
|
||||
CCreatedCoder &cod)
|
||||
{
|
||||
CMyComPtr<ICompressFilter> filter;
|
||||
HRESULT res = CreateCoder_Index(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
index, encode,
|
||||
filter, cod);
|
||||
|
||||
if (filter)
|
||||
{
|
||||
cod.IsFilter = true;
|
||||
CFilterCoder *coderSpec = new CFilterCoder(encode);
|
||||
cod.Coder = coderSpec;
|
||||
coderSpec->Filter = filter;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CreateCoder_Id(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CMethodId methodId, bool encode,
|
||||
CMyComPtr<ICompressFilter> &filter,
|
||||
CCreatedCoder &cod)
|
||||
{
|
||||
int index = FindMethod_Index(EXTERNAL_CODECS_LOC_VARS methodId, encode);
|
||||
if (index < 0)
|
||||
return S_OK;
|
||||
return CreateCoder_Index(EXTERNAL_CODECS_LOC_VARS index, encode, filter, cod);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CreateCoder_Id(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CMethodId methodId, bool encode,
|
||||
CCreatedCoder &cod)
|
||||
{
|
||||
CMyComPtr<ICompressFilter> filter;
|
||||
HRESULT res = CreateCoder(
|
||||
HRESULT res = CreateCoder_Id(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
methodId, encode,
|
||||
filter, cod);
|
||||
@@ -393,13 +467,14 @@ HRESULT CreateCoder(
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT CreateCoder(
|
||||
|
||||
HRESULT CreateCoder_Id(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CMethodId methodId, bool encode,
|
||||
CMyComPtr<ICompressCoder> &coder)
|
||||
{
|
||||
CCreatedCoder cod;
|
||||
HRESULT res = CreateCoder(
|
||||
HRESULT res = CreateCoder_Id(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
methodId, encode,
|
||||
cod);
|
||||
@@ -413,7 +488,7 @@ HRESULT CreateFilter(
|
||||
CMyComPtr<ICompressFilter> &filter)
|
||||
{
|
||||
CCreatedCoder cod;
|
||||
return CreateCoder(
|
||||
return CreateCoder_Id(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
methodId, encode,
|
||||
filter, cod);
|
||||
|
||||
@@ -116,13 +116,12 @@ extern CExternalCodecs g_ExternalCodecs;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
bool FindMethod(
|
||||
int FindMethod_Index(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const AString &name,
|
||||
CMethodId &methodId, UInt32 &numStreams);
|
||||
bool encode,
|
||||
CMethodId &methodId,
|
||||
UInt32 &numStreams);
|
||||
|
||||
bool FindMethod(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
@@ -152,18 +151,29 @@ struct CCreatedCoder
|
||||
};
|
||||
|
||||
|
||||
HRESULT CreateCoder(
|
||||
HRESULT CreateCoder_Index(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
unsigned codecIndex, bool encode,
|
||||
CMyComPtr<ICompressFilter> &filter,
|
||||
CCreatedCoder &cod);
|
||||
|
||||
HRESULT CreateCoder_Index(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
unsigned index, bool encode,
|
||||
CCreatedCoder &cod);
|
||||
|
||||
HRESULT CreateCoder_Id(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CMethodId methodId, bool encode,
|
||||
CMyComPtr<ICompressFilter> &filter,
|
||||
CCreatedCoder &cod);
|
||||
|
||||
HRESULT CreateCoder(
|
||||
HRESULT CreateCoder_Id(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CMethodId methodId, bool encode,
|
||||
CCreatedCoder &cod);
|
||||
|
||||
HRESULT CreateCoder(
|
||||
HRESULT CreateCoder_Id(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CMethodId methodId, bool encode,
|
||||
CMyComPtr<ICompressCoder> &coder);
|
||||
|
||||
@@ -253,6 +253,9 @@ struct CNameToPropID
|
||||
const char *Name;
|
||||
};
|
||||
|
||||
|
||||
// the following are related to NCoderPropID::EEnum values
|
||||
|
||||
static const CNameToPropID g_NameToPropID[] =
|
||||
{
|
||||
{ VT_UI4, "" },
|
||||
@@ -275,7 +278,8 @@ static const CNameToPropID g_NameToPropID[] =
|
||||
{ VT_UI8, "expect" },
|
||||
{ VT_UI4, "b" },
|
||||
{ VT_UI4, "check" },
|
||||
{ VT_BSTR, "filter" }
|
||||
{ VT_BSTR, "filter" },
|
||||
{ VT_UI8, "memuse" }
|
||||
};
|
||||
|
||||
static int FindPropIdExact(const UString &name)
|
||||
@@ -293,6 +297,13 @@ static bool ConvertProperty(const PROPVARIANT &srcProp, VARTYPE varType, NCOM::C
|
||||
destProp = srcProp;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (varType == VT_UI8 && srcProp.vt == VT_UI4)
|
||||
{
|
||||
destProp = (UInt64)srcProp.ulVal;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (varType == VT_BOOL)
|
||||
{
|
||||
bool res;
|
||||
|
||||
@@ -969,6 +969,10 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *ou
|
||||
}
|
||||
}
|
||||
while (Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) != 0);
|
||||
|
||||
if (_seqInStream.Res != S_OK)
|
||||
return _seqInStream.Res;
|
||||
|
||||
if (_lzInWindow.result != SZ_OK)
|
||||
return SResToHRESULT(_lzInWindow.result);
|
||||
return m_OutStream.Flush();
|
||||
|
||||
@@ -2,81 +2,48 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
// #include <stdio.h>
|
||||
|
||||
#include "../../../C/Alloc.h"
|
||||
// #include "../../../C/CpuTicks.h"
|
||||
|
||||
#include "../Common/StreamUtils.h"
|
||||
|
||||
#include "Lzma2Decoder.h"
|
||||
|
||||
static HRESULT SResToHRESULT(SRes res)
|
||||
{
|
||||
switch (res)
|
||||
{
|
||||
case SZ_OK: return S_OK;
|
||||
case SZ_ERROR_MEM: return E_OUTOFMEMORY;
|
||||
case SZ_ERROR_PARAM: return E_INVALIDARG;
|
||||
case SZ_ERROR_UNSUPPORTED: return E_NOTIMPL;
|
||||
case SZ_ERROR_DATA: return S_FALSE;
|
||||
}
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
namespace NCompress {
|
||||
namespace NLzma2 {
|
||||
|
||||
CDecoder::CDecoder():
|
||||
_inBuf(NULL),
|
||||
_finishMode(false),
|
||||
_outSizeDefined(false),
|
||||
_outStep(1 << 22),
|
||||
_inBufSize(0),
|
||||
_inBufSizeNew(1 << 20)
|
||||
{
|
||||
Lzma2Dec_Construct(&_state);
|
||||
}
|
||||
_dec(NULL)
|
||||
, _inProcessed(0)
|
||||
, _prop(0xFF)
|
||||
, _finishMode(false)
|
||||
, _inBufSize(1 << 20)
|
||||
, _outStep(1 << 20)
|
||||
#ifndef _7ZIP_ST
|
||||
, _tryMt(1)
|
||||
, _numThreads(1)
|
||||
, _memUsage((UInt64)(sizeof(size_t)) << 28)
|
||||
#endif
|
||||
{}
|
||||
|
||||
CDecoder::~CDecoder()
|
||||
{
|
||||
Lzma2Dec_Free(&_state, &g_Alloc);
|
||||
MidFree(_inBuf);
|
||||
if (_dec)
|
||||
Lzma2DecMt_Destroy(_dec);
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::SetInBufSize(UInt32 , UInt32 size) { _inBufSizeNew = size; return S_OK; }
|
||||
STDMETHODIMP CDecoder::SetInBufSize(UInt32 , UInt32 size) { _inBufSize = size; return S_OK; }
|
||||
STDMETHODIMP CDecoder::SetOutBufSize(UInt32 , UInt32 size) { _outStep = size; return S_OK; }
|
||||
|
||||
STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *prop, UInt32 size)
|
||||
{
|
||||
if (size != 1)
|
||||
return E_NOTIMPL;
|
||||
|
||||
RINOK(SResToHRESULT(Lzma2Dec_Allocate(&_state, prop[0], &g_Alloc)));
|
||||
|
||||
if (!_inBuf || _inBufSize != _inBufSizeNew)
|
||||
{
|
||||
MidFree(_inBuf);
|
||||
_inBufSize = 0;
|
||||
_inBuf = (Byte *)MidAlloc(_inBufSizeNew);
|
||||
if (!_inBuf)
|
||||
return E_OUTOFMEMORY;
|
||||
_inBufSize = _inBufSizeNew;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
|
||||
{
|
||||
_outSizeDefined = (outSize != NULL);
|
||||
_outSize = 0;
|
||||
if (_outSizeDefined)
|
||||
_outSize = *outSize;
|
||||
_inPos = _inLim = 0;
|
||||
_inProcessed = 0;
|
||||
_outProcessed = 0;
|
||||
|
||||
Lzma2Dec_Init(&_state);
|
||||
|
||||
if (prop[0] > 40)
|
||||
return E_NOTIMPL;
|
||||
_prop = prop[0];
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -88,6 +55,137 @@ STDMETHODIMP CDecoder::SetFinishMode(UInt32 finishMode)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
|
||||
static UInt64 Get_ExpectedBlockSize_From_Dict(UInt32 dictSize)
|
||||
{
|
||||
const UInt32 kMinSize = (UInt32)1 << 20;
|
||||
const UInt32 kMaxSize = (UInt32)1 << 28;
|
||||
UInt64 blockSize = (UInt64)dictSize << 2;
|
||||
if (blockSize < kMinSize) blockSize = kMinSize;
|
||||
if (blockSize > kMaxSize) blockSize = kMaxSize;
|
||||
if (blockSize < dictSize) blockSize = dictSize;
|
||||
blockSize += (kMinSize - 1);
|
||||
blockSize &= ~(UInt64)(kMinSize - 1);
|
||||
return blockSize;
|
||||
}
|
||||
|
||||
#define LZMA2_DIC_SIZE_FROM_PROP_FULL(p) ((p) == 40 ? 0xFFFFFFFF : (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11)))
|
||||
|
||||
#endif
|
||||
|
||||
#define RET_IF_WRAP_ERROR_CONFIRMED(wrapRes, sRes, sResErrorCode) \
|
||||
if (wrapRes != S_OK && sRes == sResErrorCode) return wrapRes;
|
||||
|
||||
#define RET_IF_WRAP_ERROR(wrapRes, sRes, sResErrorCode) \
|
||||
if (wrapRes != S_OK /* && (sRes == SZ_OK || sRes == sResErrorCode) */) return wrapRes;
|
||||
|
||||
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
|
||||
{
|
||||
_inProcessed = 0;
|
||||
|
||||
if (!_dec)
|
||||
{
|
||||
_dec = Lzma2DecMt_Create(
|
||||
// &g_AlignedAlloc,
|
||||
&g_Alloc,
|
||||
&g_MidAlloc);
|
||||
if (!_dec)
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
CLzma2DecMtProps props;
|
||||
Lzma2DecMtProps_Init(&props);
|
||||
|
||||
props.inBufSize_ST = _inBufSize;
|
||||
props.outStep_ST = _outStep;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
{
|
||||
props.numThreads = 1;
|
||||
UInt32 numThreads = _numThreads;
|
||||
|
||||
if (_tryMt && numThreads >= 1)
|
||||
{
|
||||
UInt64 useLimit = _memUsage;
|
||||
UInt32 dictSize = LZMA2_DIC_SIZE_FROM_PROP_FULL(_prop);
|
||||
UInt64 expectedBlockSize64 = Get_ExpectedBlockSize_From_Dict(dictSize);
|
||||
size_t expectedBlockSize = (size_t)expectedBlockSize64;
|
||||
size_t inBlockMax = expectedBlockSize + expectedBlockSize / 16;
|
||||
if (expectedBlockSize == expectedBlockSize64 && inBlockMax >= expectedBlockSize)
|
||||
{
|
||||
props.outBlockMax = expectedBlockSize;
|
||||
props.inBlockMax = inBlockMax;
|
||||
const size_t kOverheadSize = props.inBufSize_MT + (1 << 16);
|
||||
UInt64 okThreads = useLimit / (props.outBlockMax + props.inBlockMax + kOverheadSize);
|
||||
if (numThreads > okThreads)
|
||||
numThreads = (UInt32)okThreads;
|
||||
if (numThreads == 0)
|
||||
numThreads = 1;
|
||||
props.numThreads = numThreads;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
CSeqInStreamWrap inWrap;
|
||||
CSeqOutStreamWrap outWrap;
|
||||
CCompressProgressWrap progressWrap;
|
||||
|
||||
inWrap.Init(inStream);
|
||||
outWrap.Init(outStream);
|
||||
progressWrap.Init(progress);
|
||||
|
||||
SRes res;
|
||||
|
||||
UInt64 inProcessed = 0;
|
||||
int isMT = False;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
isMT = _tryMt;
|
||||
#endif
|
||||
|
||||
// UInt64 cpuTicks = GetCpuTicks();
|
||||
|
||||
res = Lzma2DecMt_Decode(_dec, _prop, &props,
|
||||
&outWrap.vt, outSize, _finishMode,
|
||||
&inWrap.vt,
|
||||
&inProcessed,
|
||||
&isMT,
|
||||
progress ? &progressWrap.vt : NULL);
|
||||
|
||||
/*
|
||||
cpuTicks = GetCpuTicks() - cpuTicks;
|
||||
printf("\n ticks = %10I64u\n", cpuTicks / 1000000);
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
/* we reset _tryMt, only if p->props.numThreads was changed */
|
||||
if (props.numThreads > 1)
|
||||
_tryMt = isMT;
|
||||
#endif
|
||||
|
||||
_inProcessed = inProcessed;
|
||||
|
||||
RET_IF_WRAP_ERROR(progressWrap.Res, res, SZ_ERROR_PROGRESS)
|
||||
RET_IF_WRAP_ERROR(outWrap.Res, res, SZ_ERROR_WRITE)
|
||||
RET_IF_WRAP_ERROR_CONFIRMED(inWrap.Res, res, SZ_ERROR_READ)
|
||||
|
||||
if (res == SZ_OK && _finishMode)
|
||||
{
|
||||
if (inSize && *inSize != inProcessed)
|
||||
res = SZ_ERROR_DATA;
|
||||
if (outSize && *outSize != outWrap.Processed)
|
||||
res = SZ_ERROR_DATA;
|
||||
}
|
||||
|
||||
return SResToHRESULT(res);
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value)
|
||||
{
|
||||
*value = _inProcessed;
|
||||
@@ -95,109 +193,51 @@ STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value)
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
|
||||
#ifndef _7ZIP_ST
|
||||
|
||||
STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads)
|
||||
{
|
||||
if (!_inBuf)
|
||||
return S_FALSE;
|
||||
|
||||
SetOutStreamSize(outSize);
|
||||
|
||||
SizeT wrPos = _state.decoder.dicPos;
|
||||
HRESULT readRes = S_OK;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (_inPos == _inLim && readRes == S_OK)
|
||||
{
|
||||
_inPos = _inLim = 0;
|
||||
readRes = inStream->Read(_inBuf, _inBufSize, &_inLim);
|
||||
}
|
||||
|
||||
const SizeT dicPos = _state.decoder.dicPos;
|
||||
SizeT size;
|
||||
{
|
||||
SizeT next = _state.decoder.dicBufSize;
|
||||
if (next - wrPos > _outStep)
|
||||
next = wrPos + _outStep;
|
||||
size = next - dicPos;
|
||||
}
|
||||
|
||||
ELzmaFinishMode finishMode = LZMA_FINISH_ANY;
|
||||
if (_outSizeDefined)
|
||||
{
|
||||
const UInt64 rem = _outSize - _outProcessed;
|
||||
if (size >= rem)
|
||||
{
|
||||
size = (SizeT)rem;
|
||||
if (_finishMode)
|
||||
finishMode = LZMA_FINISH_END;
|
||||
}
|
||||
}
|
||||
|
||||
SizeT inProcessed = _inLim - _inPos;
|
||||
ELzmaStatus status;
|
||||
|
||||
SRes res = Lzma2Dec_DecodeToDic(&_state, dicPos + size, _inBuf + _inPos, &inProcessed, finishMode, &status);
|
||||
|
||||
|
||||
_inPos += (UInt32)inProcessed;
|
||||
_inProcessed += inProcessed;
|
||||
const SizeT outProcessed = _state.decoder.dicPos - dicPos;
|
||||
_outProcessed += outProcessed;
|
||||
|
||||
|
||||
bool outFinished = (_outSizeDefined && _outProcessed >= _outSize);
|
||||
|
||||
bool needStop = (res != 0
|
||||
|| (inProcessed == 0 && outProcessed == 0)
|
||||
|| status == LZMA_STATUS_FINISHED_WITH_MARK
|
||||
|| (!_finishMode && outFinished));
|
||||
|
||||
if (needStop || outProcessed >= size)
|
||||
{
|
||||
HRESULT res2 = WriteStream(outStream, _state.decoder.dic + wrPos, _state.decoder.dicPos - wrPos);
|
||||
|
||||
if (_state.decoder.dicPos == _state.decoder.dicBufSize)
|
||||
_state.decoder.dicPos = 0;
|
||||
wrPos = _state.decoder.dicPos;
|
||||
|
||||
RINOK(res2);
|
||||
|
||||
if (needStop)
|
||||
{
|
||||
if (res != 0)
|
||||
return S_FALSE;
|
||||
|
||||
if (status == LZMA_STATUS_FINISHED_WITH_MARK)
|
||||
{
|
||||
if (_finishMode)
|
||||
{
|
||||
if (inSize && *inSize != _inProcessed)
|
||||
return S_FALSE;
|
||||
if (_outSizeDefined && _outSize != _outProcessed)
|
||||
return S_FALSE;
|
||||
}
|
||||
return readRes;
|
||||
}
|
||||
|
||||
if (!_finishMode && outFinished)
|
||||
return readRes;
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (progress)
|
||||
{
|
||||
RINOK(progress->SetRatioInfo(&_inProcessed, &_outProcessed));
|
||||
}
|
||||
}
|
||||
_numThreads = numThreads;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::SetMemLimit(UInt64 memUsage)
|
||||
{
|
||||
_memUsage = memUsage;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NO_READ_FROM_CODER
|
||||
|
||||
STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
|
||||
{
|
||||
CLzma2DecMtProps props;
|
||||
Lzma2DecMtProps_Init(&props);
|
||||
props.inBufSize_ST = _inBufSize;
|
||||
props.outStep_ST = _outStep;
|
||||
|
||||
_inProcessed = 0;
|
||||
|
||||
if (!_dec)
|
||||
{
|
||||
_dec = Lzma2DecMt_Create(&g_AlignedAlloc, &g_MidAlloc);
|
||||
if (!_dec)
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
_inWrap.Init(_inStream);
|
||||
|
||||
SRes res = Lzma2DecMt_Init(_dec, _prop, &props, outSize, _finishMode, &_inWrap.vt);
|
||||
|
||||
if (res != SZ_OK)
|
||||
return SResToHRESULT(res);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) { _inStream = inStream; return S_OK; }
|
||||
STDMETHODIMP CDecoder::ReleaseInStream() { _inStream.Release(); return S_OK; }
|
||||
|
||||
@@ -207,62 +247,17 @@ STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
if (processedSize)
|
||||
*processedSize = 0;
|
||||
|
||||
ELzmaFinishMode finishMode = LZMA_FINISH_ANY;
|
||||
if (_outSizeDefined)
|
||||
{
|
||||
const UInt64 rem = _outSize - _outProcessed;
|
||||
if (size >= rem)
|
||||
{
|
||||
size = (UInt32)rem;
|
||||
if (_finishMode)
|
||||
finishMode = LZMA_FINISH_END;
|
||||
}
|
||||
}
|
||||
size_t size2 = size;
|
||||
UInt64 inProcessed = 0;
|
||||
|
||||
HRESULT readRes = S_OK;
|
||||
SRes res = Lzma2DecMt_Read(_dec, (Byte *)data, &size2, &inProcessed);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (_inPos == _inLim && readRes == S_OK)
|
||||
{
|
||||
_inPos = _inLim = 0;
|
||||
readRes = _inStream->Read(_inBuf, _inBufSize, &_inLim);
|
||||
}
|
||||
|
||||
SizeT inProcessed = _inLim - _inPos;
|
||||
SizeT outProcessed = size;
|
||||
ELzmaStatus status;
|
||||
|
||||
SRes res = Lzma2Dec_DecodeToBuf(&_state, (Byte *)data, &outProcessed,
|
||||
_inBuf + _inPos, &inProcessed, finishMode, &status);
|
||||
|
||||
|
||||
_inPos += (UInt32)inProcessed;
|
||||
_inProcessed += inProcessed;
|
||||
_outProcessed += outProcessed;
|
||||
size -= (UInt32)outProcessed;
|
||||
data = (Byte *)data + outProcessed;
|
||||
if (processedSize)
|
||||
*processedSize += (UInt32)outProcessed;
|
||||
|
||||
if (res != 0)
|
||||
return S_FALSE;
|
||||
|
||||
/*
|
||||
if (status == LZMA_STATUS_FINISHED_WITH_MARK)
|
||||
return readRes;
|
||||
|
||||
if (size == 0 && status != LZMA_STATUS_NEEDS_MORE_INPUT)
|
||||
{
|
||||
if (_finishMode && _outSizeDefined && _outProcessed >= _outSize)
|
||||
return S_FALSE;
|
||||
return readRes;
|
||||
}
|
||||
*/
|
||||
|
||||
if (inProcessed == 0 && outProcessed == 0)
|
||||
return readRes;
|
||||
}
|
||||
_inProcessed += inProcessed;
|
||||
if (processedSize)
|
||||
*processedSize = (UInt32)size2;
|
||||
if (res != SZ_OK)
|
||||
return SResToHRESULT(res);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,10 +3,9 @@
|
||||
#ifndef __LZMA2_DECODER_H
|
||||
#define __LZMA2_DECODER_H
|
||||
|
||||
#include "../../../C/Lzma2Dec.h"
|
||||
#include "../../../C/Lzma2DecMt.h"
|
||||
|
||||
#include "../../Common/MyCom.h"
|
||||
#include "../ICoder.h"
|
||||
#include "../Common/CWrappers.h"
|
||||
|
||||
namespace NCompress {
|
||||
namespace NLzma2 {
|
||||
@@ -17,28 +16,26 @@ class CDecoder:
|
||||
public ICompressSetFinishMode,
|
||||
public ICompressGetInStreamProcessedSize,
|
||||
public ICompressSetBufSize,
|
||||
|
||||
#ifndef NO_READ_FROM_CODER
|
||||
public ICompressSetInStream,
|
||||
public ICompressSetOutStreamSize,
|
||||
public ISequentialInStream,
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
public ICompressSetCoderMt,
|
||||
public ICompressSetMemLimit,
|
||||
#endif
|
||||
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Byte *_inBuf;
|
||||
UInt32 _inPos;
|
||||
UInt32 _inLim;
|
||||
|
||||
bool _finishMode;
|
||||
bool _outSizeDefined;
|
||||
UInt64 _outSize;
|
||||
CLzma2DecMtHandle _dec;
|
||||
UInt64 _inProcessed;
|
||||
UInt64 _outProcessed;
|
||||
|
||||
UInt32 _outStep;
|
||||
Byte _prop;
|
||||
int _finishMode;
|
||||
UInt32 _inBufSize;
|
||||
UInt32 _inBufSizeNew;
|
||||
|
||||
CLzma2Dec _state;
|
||||
UInt32 _outStep;
|
||||
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
|
||||
@@ -46,11 +43,18 @@ public:
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetFinishMode)
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressGetInStreamProcessedSize)
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetBufSize)
|
||||
|
||||
#ifndef NO_READ_FROM_CODER
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetOutStreamSize)
|
||||
MY_QUERYINTERFACE_ENTRY(ISequentialInStream)
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetCoderMt)
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetMemLimit)
|
||||
#endif
|
||||
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
@@ -59,20 +63,28 @@ public:
|
||||
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
|
||||
STDMETHOD(SetFinishMode)(UInt32 finishMode);
|
||||
STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
|
||||
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
|
||||
STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size);
|
||||
STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size);
|
||||
|
||||
#ifndef NO_READ_FROM_CODER
|
||||
#ifndef _7ZIP_ST
|
||||
private:
|
||||
int _tryMt;
|
||||
UInt32 _numThreads;
|
||||
UInt64 _memUsage;
|
||||
public:
|
||||
STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
|
||||
STDMETHOD(SetMemLimit)(UInt64 memUsage);
|
||||
#endif
|
||||
|
||||
#ifndef NO_READ_FROM_CODER
|
||||
private:
|
||||
CMyComPtr<ISequentialInStream> _inStream;
|
||||
CSeqInStreamWrap _inWrap;
|
||||
public:
|
||||
|
||||
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
|
||||
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
|
||||
STDMETHOD(ReleaseInStream)();
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
|
||||
#endif
|
||||
|
||||
CDecoder();
|
||||
|
||||
@@ -30,19 +30,24 @@ CDecoder::CDecoder():
|
||||
FinishStream(false),
|
||||
_propsWereSet(false),
|
||||
_outSizeDefined(false),
|
||||
_outStep(1 << 22),
|
||||
_outStep(1 << 20),
|
||||
_inBufSize(0),
|
||||
_inBufSizeNew(1 << 20)
|
||||
{
|
||||
_inProcessed = 0;
|
||||
_inPos = _inLim = 0;
|
||||
|
||||
/*
|
||||
AlignOffsetAlloc_CreateVTable(&_alloc);
|
||||
_alloc.numAlignBits = 7;
|
||||
_alloc.offset = 0;
|
||||
*/
|
||||
LzmaDec_Construct(&_state);
|
||||
}
|
||||
|
||||
CDecoder::~CDecoder()
|
||||
{
|
||||
LzmaDec_Free(&_state, &g_Alloc);
|
||||
LzmaDec_Free(&_state, &g_AlignedAlloc); // &_alloc.vt
|
||||
MyFree(_inBuf);
|
||||
}
|
||||
|
||||
@@ -66,7 +71,7 @@ HRESULT CDecoder::CreateInputBuffer()
|
||||
|
||||
STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *prop, UInt32 size)
|
||||
{
|
||||
RINOK(SResToHRESULT(LzmaDec_Allocate(&_state, prop, size, &g_Alloc)));
|
||||
RINOK(SResToHRESULT(LzmaDec_Allocate(&_state, prop, size, &g_AlignedAlloc))) // &_alloc.vt
|
||||
_propsWereSet = true;
|
||||
return CreateInputBuffer();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#ifndef __LZMA_DECODER_H
|
||||
#define __LZMA_DECODER_H
|
||||
|
||||
// #include "../../../C/Alloc.h"
|
||||
#include "../../../C/LzmaDec.h"
|
||||
|
||||
#include "../../Common/MyCom.h"
|
||||
@@ -28,7 +29,6 @@ class CDecoder:
|
||||
UInt32 _inPos;
|
||||
UInt32 _inLim;
|
||||
|
||||
CLzmaDec _state;
|
||||
ELzmaStatus _lzmaStatus;
|
||||
|
||||
public:
|
||||
@@ -45,6 +45,10 @@ private:
|
||||
UInt32 _inBufSize;
|
||||
UInt32 _inBufSizeNew;
|
||||
|
||||
// CAlignOffsetAlloc _alloc;
|
||||
|
||||
CLzmaDec _state;
|
||||
|
||||
HRESULT CreateInputBuffer();
|
||||
HRESULT CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress);
|
||||
void SetOutStreamSizeResume(const UInt64 *outSize);
|
||||
|
||||
@@ -4,248 +4,119 @@
|
||||
|
||||
#include "../../../C/Alloc.h"
|
||||
|
||||
#include "../Common/StreamUtils.h"
|
||||
|
||||
#include "../Archive/IArchive.h"
|
||||
#include "../Common/CWrappers.h"
|
||||
|
||||
#include "XzDecoder.h"
|
||||
|
||||
using namespace NArchive;
|
||||
|
||||
namespace NCompress {
|
||||
namespace NXz {
|
||||
|
||||
#define RET_IF_WRAP_ERROR_CONFIRMED(wrapRes, sRes, sResErrorCode) \
|
||||
if (wrapRes != S_OK && sRes == sResErrorCode) return wrapRes;
|
||||
|
||||
CXzUnpackerCPP::CXzUnpackerCPP(): InBuf(NULL), OutBuf(NULL)
|
||||
#define RET_IF_WRAP_ERROR(wrapRes, sRes, sResErrorCode) \
|
||||
if (wrapRes != S_OK /* && (sRes == SZ_OK || sRes == sResErrorCode) */) return wrapRes;
|
||||
|
||||
static HRESULT SResToHRESULT_Code(SRes res) throw()
|
||||
{
|
||||
XzUnpacker_Construct(&p, &g_Alloc);
|
||||
}
|
||||
|
||||
CXzUnpackerCPP::~CXzUnpackerCPP()
|
||||
{
|
||||
XzUnpacker_Free(&p);
|
||||
MidFree(InBuf);
|
||||
MidFree(OutBuf);
|
||||
}
|
||||
|
||||
|
||||
void CStatInfo::Clear()
|
||||
{
|
||||
InSize = 0;
|
||||
OutSize = 0;
|
||||
PhySize = 0;
|
||||
|
||||
NumStreams = 0;
|
||||
NumBlocks = 0;
|
||||
|
||||
UnpackSize_Defined = false;
|
||||
|
||||
NumStreams_Defined = false;
|
||||
NumBlocks_Defined = false;
|
||||
|
||||
IsArc = false;
|
||||
UnexpectedEnd = false;
|
||||
DataAfterEnd = false;
|
||||
Unsupported = false;
|
||||
HeadersError = false;
|
||||
DataError = false;
|
||||
CrcError = false;
|
||||
if (res < 0)
|
||||
return res;
|
||||
switch (res)
|
||||
{
|
||||
case SZ_OK: return S_OK;
|
||||
case SZ_ERROR_MEM: return E_OUTOFMEMORY;
|
||||
case SZ_ERROR_UNSUPPORTED: return E_NOTIMPL;
|
||||
}
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CDecoder::Decode(ISequentialInStream *seqInStream, ISequentialOutStream *outStream,
|
||||
const UInt64 *outSizeLimit, bool finishStream, ICompressProgressInfo *progress)
|
||||
{
|
||||
const size_t kInBufSize = (size_t)1 << 20;
|
||||
const size_t kOutBufSize = (size_t)1 << 21;
|
||||
MainDecodeSRes = S_OK;
|
||||
MainDecodeSRes_wasUsed = false;
|
||||
XzStatInfo_Clear(&Stat);
|
||||
|
||||
Clear();
|
||||
DecodeRes = SZ_OK;
|
||||
|
||||
XzUnpacker_Init(&xzu.p);
|
||||
|
||||
if (!xzu.InBuf)
|
||||
if (!xz)
|
||||
{
|
||||
xzu.InBuf = (Byte *)MidAlloc(kInBufSize);
|
||||
if (!xzu.InBuf)
|
||||
xz = XzDecMt_Create(&g_Alloc, &g_MidAlloc);
|
||||
if (!xz)
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
if (!xzu.OutBuf)
|
||||
{
|
||||
xzu.OutBuf = (Byte *)MidAlloc(kOutBufSize);
|
||||
if (!xzu.OutBuf)
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
UInt32 inSize = 0;
|
||||
UInt32 inPos = 0;
|
||||
SizeT outPos = 0;
|
||||
|
||||
HRESULT readRes = S_OK;
|
||||
CXzDecMtProps props;
|
||||
XzDecMtProps_Init(&props);
|
||||
|
||||
for (;;)
|
||||
int isMT = False;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
{
|
||||
if (inPos == inSize && readRes == S_OK)
|
||||
props.numThreads = 1;
|
||||
UInt32 numThreads = _numThreads;
|
||||
|
||||
if (_tryMt && numThreads > 1)
|
||||
{
|
||||
inPos = inSize = 0;
|
||||
readRes = seqInStream->Read(xzu.InBuf, kInBufSize, &inSize);
|
||||
size_t memUsage = (size_t)_memUsage;
|
||||
if (memUsage != _memUsage)
|
||||
memUsage = (size_t)0 - 1;
|
||||
props.memUseMax = memUsage;
|
||||
isMT = (numThreads > 1);
|
||||
}
|
||||
|
||||
SizeT inLen = inSize - inPos;
|
||||
SizeT outLen = kOutBufSize - outPos;
|
||||
ECoderFinishMode finishMode = CODER_FINISH_ANY;
|
||||
props.numThreads = numThreads;
|
||||
}
|
||||
#endif
|
||||
|
||||
CSeqInStreamWrap inWrap;
|
||||
CSeqOutStreamWrap outWrap;
|
||||
CCompressProgressWrap progressWrap;
|
||||
|
||||
inWrap.Init(seqInStream);
|
||||
outWrap.Init(outStream);
|
||||
progressWrap.Init(progress);
|
||||
|
||||
SRes res = XzDecMt_Decode(xz,
|
||||
&props,
|
||||
outSizeLimit, finishStream,
|
||||
&outWrap.vt,
|
||||
&inWrap.vt,
|
||||
&Stat,
|
||||
&isMT,
|
||||
progress ? &progressWrap.vt : NULL);
|
||||
|
||||
MainDecodeSRes = res;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
// _tryMt = isMT;
|
||||
#endif
|
||||
|
||||
RET_IF_WRAP_ERROR(outWrap.Res, res, SZ_ERROR_WRITE)
|
||||
RET_IF_WRAP_ERROR(progressWrap.Res, res, SZ_ERROR_PROGRESS)
|
||||
RET_IF_WRAP_ERROR_CONFIRMED(inWrap.Res, res, SZ_ERROR_READ)
|
||||
|
||||
// return E_OUTOFMEMORY;
|
||||
|
||||
MainDecodeSRes_wasUsed = true;
|
||||
|
||||
if (res == SZ_OK && finishStream)
|
||||
{
|
||||
/*
|
||||
// 17.01 : the code was disabled:
|
||||
if (inSize == 0)
|
||||
finishMode = CODER_FINISH_END;
|
||||
if (inSize && *inSize != Stat.PhySize)
|
||||
res = SZ_ERROR_DATA;
|
||||
*/
|
||||
|
||||
if (outSizeLimit)
|
||||
{
|
||||
const UInt64 rem = *outSizeLimit - OutSize;
|
||||
if (outLen >= rem)
|
||||
{
|
||||
outLen = (SizeT)rem;
|
||||
if (finishStream)
|
||||
finishMode = CODER_FINISH_END;
|
||||
}
|
||||
}
|
||||
|
||||
ECoderStatus status;
|
||||
|
||||
const SizeT outLenRequested = outLen;
|
||||
|
||||
SRes res = XzUnpacker_Code(&xzu.p,
|
||||
xzu.OutBuf + outPos, &outLen,
|
||||
xzu.InBuf + inPos, &inLen,
|
||||
finishMode, &status);
|
||||
|
||||
DecodeRes = res;
|
||||
|
||||
inPos += (UInt32)inLen;
|
||||
outPos += outLen;
|
||||
|
||||
InSize += inLen;
|
||||
OutSize += outLen;
|
||||
|
||||
bool finished = ((inLen == 0 && outLen == 0) || res != SZ_OK);
|
||||
|
||||
if (outLen >= outLenRequested || finished)
|
||||
{
|
||||
if (outStream && outPos != 0)
|
||||
{
|
||||
RINOK(WriteStream(outStream, xzu.OutBuf, outPos));
|
||||
}
|
||||
outPos = 0;
|
||||
}
|
||||
|
||||
if (progress)
|
||||
{
|
||||
RINOK(progress->SetRatioInfo(&InSize, &OutSize));
|
||||
}
|
||||
|
||||
if (!finished)
|
||||
continue;
|
||||
|
||||
{
|
||||
PhySize = InSize;
|
||||
NumStreams = xzu.p.numStartedStreams;
|
||||
if (NumStreams > 0)
|
||||
IsArc = true;
|
||||
NumBlocks = xzu.p.numTotalBlocks;
|
||||
|
||||
UnpackSize_Defined = true;
|
||||
NumStreams_Defined = true;
|
||||
NumBlocks_Defined = true;
|
||||
|
||||
UInt64 extraSize = XzUnpacker_GetExtraSize(&xzu.p);
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
if (status == CODER_STATUS_NEEDS_MORE_INPUT)
|
||||
{
|
||||
extraSize = 0;
|
||||
if (!XzUnpacker_IsStreamWasFinished(&xzu.p))
|
||||
{
|
||||
// finished at padding bytes, but padding is not aligned for 4
|
||||
UnexpectedEnd = true;
|
||||
res = SZ_ERROR_DATA;
|
||||
}
|
||||
}
|
||||
else // status == CODER_STATUS_NOT_FINISHED
|
||||
res = SZ_ERROR_DATA;
|
||||
}
|
||||
else if (res == SZ_ERROR_NO_ARCHIVE)
|
||||
{
|
||||
if (InSize == extraSize)
|
||||
IsArc = false;
|
||||
else
|
||||
{
|
||||
if (extraSize != 0 || inPos != inSize)
|
||||
{
|
||||
DataAfterEnd = true;
|
||||
res = SZ_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DecodeRes = res;
|
||||
PhySize -= extraSize;
|
||||
|
||||
switch (res)
|
||||
{
|
||||
case SZ_OK: break;
|
||||
case SZ_ERROR_NO_ARCHIVE: IsArc = false; break;
|
||||
case SZ_ERROR_ARCHIVE: HeadersError = true; break;
|
||||
case SZ_ERROR_UNSUPPORTED: Unsupported = true; break;
|
||||
case SZ_ERROR_CRC: CrcError = true; break;
|
||||
case SZ_ERROR_DATA: DataError = true; break;
|
||||
default: DataError = true; break;
|
||||
}
|
||||
|
||||
return readRes;
|
||||
}
|
||||
if (outSizeLimit && *outSizeLimit != outWrap.Processed)
|
||||
res = SZ_ERROR_DATA;
|
||||
}
|
||||
|
||||
return SResToHRESULT_Code(res);
|
||||
}
|
||||
|
||||
|
||||
Int32 CDecoder::Get_Extract_OperationResult() const
|
||||
{
|
||||
Int32 opRes;
|
||||
if (!IsArc)
|
||||
opRes = NExtract::NOperationResult::kIsNotArc;
|
||||
else if (UnexpectedEnd)
|
||||
opRes = NExtract::NOperationResult::kUnexpectedEnd;
|
||||
else if (DataAfterEnd)
|
||||
opRes = NExtract::NOperationResult::kDataAfterEnd;
|
||||
else if (CrcError)
|
||||
opRes = NExtract::NOperationResult::kCRCError;
|
||||
else if (Unsupported)
|
||||
opRes = NExtract::NOperationResult::kUnsupportedMethod;
|
||||
else if (HeadersError)
|
||||
opRes = NExtract::NOperationResult::kDataError;
|
||||
else if (DataError)
|
||||
opRes = NExtract::NOperationResult::kDataError;
|
||||
else if (DecodeRes != SZ_OK)
|
||||
opRes = NExtract::NOperationResult::kDataError;
|
||||
else
|
||||
opRes = NExtract::NOperationResult::kOK;
|
||||
return opRes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT CComDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
|
||||
{
|
||||
RINOK(_decoder.Decode(inStream, outStream, outSize, _finishStream, progress));
|
||||
Int32 opRes = _decoder.Get_Extract_OperationResult();
|
||||
if (opRes == NArchive::NExtract::NOperationResult::kUnsupportedMethod)
|
||||
return E_NOTIMPL;
|
||||
if (opRes != NArchive::NExtract::NOperationResult::kOK)
|
||||
return S_FALSE;
|
||||
return S_OK;
|
||||
return Decode(inStream, outStream, outSize, _finishStream, progress);
|
||||
}
|
||||
|
||||
STDMETHODIMP CComDecoder::SetFinishMode(UInt32 finishMode)
|
||||
@@ -256,8 +127,24 @@ STDMETHODIMP CComDecoder::SetFinishMode(UInt32 finishMode)
|
||||
|
||||
STDMETHODIMP CComDecoder::GetInStreamProcessedSize(UInt64 *value)
|
||||
{
|
||||
*value = _decoder.InSize;
|
||||
*value = Stat.InSize;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
|
||||
STDMETHODIMP CComDecoder::SetNumberOfThreads(UInt32 numThreads)
|
||||
{
|
||||
_numThreads = numThreads;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CComDecoder::SetMemLimit(UInt64 memUsage)
|
||||
{
|
||||
_memUsage = memUsage;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
@@ -12,57 +12,36 @@
|
||||
namespace NCompress {
|
||||
namespace NXz {
|
||||
|
||||
struct CXzUnpackerCPP
|
||||
struct CDecoder
|
||||
{
|
||||
Byte *InBuf;
|
||||
Byte *OutBuf;
|
||||
CXzUnpacker p;
|
||||
CXzDecMtHandle xz;
|
||||
int _tryMt;
|
||||
UInt32 _numThreads;
|
||||
UInt64 _memUsage;
|
||||
|
||||
SRes MainDecodeSRes; // it's not HRESULT
|
||||
bool MainDecodeSRes_wasUsed;
|
||||
CXzStatInfo Stat;
|
||||
|
||||
CDecoder():
|
||||
xz(NULL),
|
||||
_tryMt(True),
|
||||
_numThreads(1),
|
||||
_memUsage((UInt64)(sizeof(size_t)) << 28),
|
||||
MainDecodeSRes(SZ_OK),
|
||||
MainDecodeSRes_wasUsed(false)
|
||||
{}
|
||||
|
||||
CXzUnpackerCPP();
|
||||
~CXzUnpackerCPP();
|
||||
};
|
||||
|
||||
|
||||
struct CStatInfo
|
||||
{
|
||||
UInt64 InSize;
|
||||
UInt64 OutSize;
|
||||
UInt64 PhySize;
|
||||
|
||||
UInt64 NumStreams;
|
||||
UInt64 NumBlocks;
|
||||
|
||||
bool UnpackSize_Defined;
|
||||
|
||||
bool NumStreams_Defined;
|
||||
bool NumBlocks_Defined;
|
||||
|
||||
bool IsArc;
|
||||
bool UnexpectedEnd;
|
||||
bool DataAfterEnd;
|
||||
bool Unsupported;
|
||||
bool HeadersError;
|
||||
bool DataError;
|
||||
bool CrcError;
|
||||
|
||||
CStatInfo() { Clear(); }
|
||||
|
||||
void Clear();
|
||||
};
|
||||
|
||||
|
||||
struct CDecoder: public CStatInfo
|
||||
{
|
||||
CXzUnpackerCPP xzu;
|
||||
SRes DecodeRes; // it's not HRESULT
|
||||
|
||||
CDecoder(): DecodeRes(SZ_OK) {}
|
||||
~CDecoder()
|
||||
{
|
||||
if (xz)
|
||||
XzDecMt_Destroy(xz);
|
||||
}
|
||||
|
||||
/* Decode() can return ERROR code only if there is progress or stream error.
|
||||
Decode() returns S_OK in case of xz decoding error, but DecodeRes and CStatInfo contain error information */
|
||||
HRESULT Decode(ISequentialInStream *seqInStream, ISequentialOutStream *outStream,
|
||||
const UInt64 *outSizeLimit, bool finishStream, ICompressProgressInfo *compressProgress);
|
||||
Int32 Get_Extract_OperationResult() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -70,21 +49,41 @@ class CComDecoder:
|
||||
public ICompressCoder,
|
||||
public ICompressSetFinishMode,
|
||||
public ICompressGetInStreamProcessedSize,
|
||||
public CMyUnknownImp
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
public ICompressSetCoderMt,
|
||||
public ICompressSetMemLimit,
|
||||
#endif
|
||||
|
||||
public CMyUnknownImp,
|
||||
public CDecoder
|
||||
{
|
||||
CDecoder _decoder;
|
||||
bool _finishStream;
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP2(
|
||||
ICompressSetFinishMode,
|
||||
ICompressGetInStreamProcessedSize)
|
||||
MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
|
||||
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetFinishMode)
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressGetInStreamProcessedSize)
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetCoderMt)
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetMemLimit)
|
||||
#endif
|
||||
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
|
||||
STDMETHOD(SetFinishMode)(UInt32 finishMode);
|
||||
STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
|
||||
STDMETHOD(SetMemLimit)(UInt64 memUsage);
|
||||
#endif
|
||||
|
||||
CComDecoder(): _finishStream(false) {}
|
||||
};
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
25 ICompressSetCoderMt
|
||||
26 ICompressSetFinishMode
|
||||
27 ICompressGetInStreamProcessedSize2
|
||||
28 ICompressSetMemLimit
|
||||
|
||||
30 ICompressGetSubStreamSize
|
||||
31 ICompressSetInStream
|
||||
@@ -165,6 +166,7 @@ Handler GUIDs:
|
||||
0C xz
|
||||
0D ppmd
|
||||
|
||||
C6 COFF
|
||||
C7 Ext
|
||||
C8 VMDK
|
||||
C9 VDI
|
||||
|
||||
@@ -43,6 +43,7 @@ CODER_INTERFACE(ICompressCoder2, 0x18)
|
||||
S_OK : OK
|
||||
S_FALSE : data error (for decoders)
|
||||
E_OUTOFMEMORY : memory allocation error
|
||||
E_NOTIMPL : unsupported encoding method (for decoders)
|
||||
another error code : some error. For example, it can be error code received from inStream or outStream function.
|
||||
|
||||
Parameters:
|
||||
@@ -129,7 +130,8 @@ namespace NCoderPropID
|
||||
|
||||
kBlockSize2, // VT_UI4 or VT_UI8
|
||||
kCheckSize, // VT_UI4 : size of digest in bytes
|
||||
kFilter // VT_BSTR
|
||||
kFilter, // VT_BSTR
|
||||
kMemUse // VT_UI8
|
||||
};
|
||||
}
|
||||
|
||||
@@ -190,6 +192,12 @@ CODER_INTERFACE(ICompressGetInStreamProcessedSize2, 0x27)
|
||||
STDMETHOD(GetInStreamProcessedSize2)(UInt32 streamIndex, UInt64 *value) PURE;
|
||||
};
|
||||
|
||||
CODER_INTERFACE(ICompressSetMemLimit, 0x28)
|
||||
{
|
||||
STDMETHOD(SetMemLimit)(UInt64 memUsage) PURE;
|
||||
};
|
||||
|
||||
|
||||
|
||||
CODER_INTERFACE(ICompressGetSubStreamSize, 0x30)
|
||||
{
|
||||
|
||||
5
CPP/7zip/LzmaDec.mak
Normal file
5
CPP/7zip/LzmaDec.mak
Normal file
@@ -0,0 +1,5 @@
|
||||
!IF "$(CPU)" == "AMD64"
|
||||
CFLAGS_C_SPEC = -D_LZMA_DEC_OPT
|
||||
ASM_OBJS = $(ASM_OBJS) \
|
||||
$O\LzmaDecOpt.obj
|
||||
!ENDIF
|
||||
@@ -253,8 +253,8 @@ public:
|
||||
IInArchive *GetArchive() const { if ( _archiveLink.Arcs.IsEmpty()) return 0; return GetArc().Archive; }
|
||||
bool CanUpdate() const;
|
||||
|
||||
bool Is_Attrib_ReadOnly() const
|
||||
{
|
||||
bool Is_Attrib_ReadOnly() const
|
||||
{
|
||||
return _attrib != INVALID_FILE_ATTRIBUTES && (_attrib & FILE_ATTRIBUTE_READONLY);
|
||||
}
|
||||
|
||||
|
||||
@@ -1183,9 +1183,11 @@ static HRESULT MethodBench(
|
||||
COneMethodInfo method = method2;
|
||||
UInt64 methodId;
|
||||
UInt32 numStreams;
|
||||
if (!FindMethod(
|
||||
int codecIndex = FindMethod_Index(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
method.MethodName, methodId, numStreams))
|
||||
method.MethodName, true,
|
||||
methodId, numStreams);
|
||||
if (codecIndex < 0)
|
||||
return E_NOTIMPL;
|
||||
if (numStreams != 1)
|
||||
return E_INVALIDARG;
|
||||
@@ -1222,7 +1224,7 @@ static HRESULT MethodBench(
|
||||
|
||||
{
|
||||
CCreatedCoder cod;
|
||||
RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS methodId, true, encoder._encoderFilter, cod));
|
||||
RINOK(CreateCoder_Index(EXTERNAL_CODECS_LOC_VARS codecIndex, true, encoder._encoderFilter, cod));
|
||||
encoder._encoder = cod.Coder;
|
||||
if (!encoder._encoder && !encoder._encoderFilter)
|
||||
return E_NOTIMPL;
|
||||
@@ -1239,7 +1241,7 @@ static HRESULT MethodBench(
|
||||
{
|
||||
CCreatedCoder cod;
|
||||
CMyComPtr<ICompressCoder> &decoder = encoder._decoders[j];
|
||||
RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS methodId, false, encoder._decoderFilter, cod));
|
||||
RINOK(CreateCoder_Id(EXTERNAL_CODECS_LOC_VARS methodId, false, encoder._decoderFilter, cod));
|
||||
decoder = cod.Coder;
|
||||
if (!encoder._decoderFilter && !decoder)
|
||||
return E_NOTIMPL;
|
||||
|
||||
@@ -115,10 +115,11 @@ COMPLB = $(CC) $(CFLAGS_O1) -Yu"StdAfx.h" -Fp$O/a.pch $<
|
||||
# COMPLB_O2 = $(CC) $(CFLAGS_O2) -Yu"StdAfx.h" -Fp$O/a.pch $<
|
||||
COMPLB_O2 = $(CC) $(CFLAGS_O2) $<
|
||||
|
||||
CCOMPL_PCH = $(CC) $(CFLAGS_O2) -Yc"Precomp.h" -Fp$O/a.pch $**
|
||||
CCOMPL_USE = $(CC) $(CFLAGS_O2) -Yu"Precomp.h" -Fp$O/a.pch $**
|
||||
CCOMPL = $(CC) $(CFLAGS_O2) $**
|
||||
CCOMPLB = $(CC) $(CFLAGS_O2) $<
|
||||
CFLAGS_C_ALL = $(CFLAGS_O2) $(CFLAGS_C_SPEC)
|
||||
CCOMPL_PCH = $(CC) $(CFLAGS_C_ALL) -Yc"Precomp.h" -Fp$O/a.pch $**
|
||||
CCOMPL_USE = $(CC) $(CFLAGS_C_ALL) -Yu"Precomp.h" -Fp$O/a.pch $**
|
||||
CCOMPL = $(CC) $(CFLAGS_C_ALL) $**
|
||||
CCOMPLB = $(CC) $(CFLAGS_C_ALL) $<
|
||||
|
||||
|
||||
all: $(PROGPATH)
|
||||
|
||||
Reference in New Issue
Block a user