Update to LZMA 16.0 [Vas Crabb]

This commit is contained in:
Vas Crabb 2016-05-12 00:06:54 +10:00
parent 6a53a6aeff
commit 7a423d0160
38 changed files with 277 additions and 114 deletions

View File

@ -1,5 +1,5 @@
/* 7zArcIn.c -- 7z Input functions /* 7zArcIn.c -- 7z Input functions
2015-11-18 : Igor Pavlov : Public domain */ 2016-03-31 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@ -788,13 +788,9 @@ static SRes ReadUnpackInfo(CSzAr *p,
numCodersOutStreams += numCoders; numCodersOutStreams += numCoders;
if (numCodersOutStreams < numCoders) if (numCodersOutStreams < numCoders)
return SZ_ERROR_UNSUPPORTED; return SZ_ERROR_UNSUPPORTED;
if (numPackStreams > p->NumPackStreams - packStreamIndex)
packStreamIndex += numPackStreams;
if (packStreamIndex < numPackStreams)
return SZ_ERROR_UNSUPPORTED;
if (packStreamIndex > p->NumPackStreams)
return SZ_ERROR_ARCHIVE; return SZ_ERROR_ARCHIVE;
packStreamIndex += numPackStreams;
} }
} }

View File

@ -1,14 +1,14 @@
#define MY_VER_MAJOR 15 #define MY_VER_MAJOR 16
#define MY_VER_MINOR 14 #define MY_VER_MINOR 00
#define MY_VER_BUILD 0 #define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "15.14" #define MY_VERSION_NUMBERS "16.00"
#define MY_VERSION "15.14" #define MY_VERSION "16.00"
#define MY_DATE "2015-12-31" #define MY_DATE "2016-05-10"
#undef MY_COPYRIGHT #undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE #undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov" #define MY_AUTHOR_NAME "Igor Pavlov"
#define MY_COPYRIGHT_PD "Igor Pavlov : Public domain" #define MY_COPYRIGHT_PD "Igor Pavlov : Public domain"
#define MY_COPYRIGHT_CR "Copyright (c) 1999-2015 Igor Pavlov" #define MY_COPYRIGHT_CR "Copyright (c) 1999-2016 Igor Pavlov"
#ifdef USE_COPYRIGHT_CR #ifdef USE_COPYRIGHT_CR
#define MY_COPYRIGHT MY_COPYRIGHT_CR #define MY_COPYRIGHT MY_COPYRIGHT_CR

View File

@ -1,5 +1,5 @@
/* CpuArch.c -- CPU specific code /* CpuArch.c -- CPU specific code
2015-03-25: Igor Pavlov : Public domain */ 2016-02-25: Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
@ -45,7 +45,8 @@ static UInt32 CheckFlag(UInt32 flag)
"push %%EDX\n\t" "push %%EDX\n\t"
"popf\n\t" "popf\n\t"
"andl %%EAX, %0\n\t": "andl %%EAX, %0\n\t":
"=c" (flag) : "c" (flag)); "=c" (flag) : "c" (flag) :
"%eax", "%edx");
#endif #endif
return flag; return flag;
} }
@ -79,7 +80,13 @@ void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
#else #else
__asm__ __volatile__ ( __asm__ __volatile__ (
#if defined(MY_CPU_X86) && defined(__PIC__) #if defined(MY_CPU_AMD64) && defined(__PIC__)
"mov %%rbx, %%rdi;"
"cpuid;"
"xchg %%rbx, %%rdi;"
: "=a" (*a) ,
"=D" (*b) ,
#elif defined(MY_CPU_X86) && defined(__PIC__)
"mov %%ebx, %%edi;" "mov %%ebx, %%edi;"
"cpuid;" "cpuid;"
"xchgl %%ebx, %%edi;" "xchgl %%ebx, %%edi;"

View File

@ -93,6 +93,8 @@ void CStreamSwitch::Set(CInArchive *archive, const CObjectVector<CByteBuffer> *d
Byte external = archive->ReadByte(); Byte external = archive->ReadByte();
if (external != 0) if (external != 0)
{ {
if (!dataVector)
ThrowIncorrect();
CNum dataIndex = archive->ReadNum(); CNum dataIndex = archive->ReadNum();
if (dataIndex >= dataVector->Size()) if (dataIndex >= dataVector->Size())
ThrowIncorrect(); ThrowIncorrect();
@ -761,6 +763,8 @@ void CInArchive::ReadUnpackInfo(
folders.FoToCoderUnpackSizes[fo] = numCodersOutStreams; folders.FoToCoderUnpackSizes[fo] = numCodersOutStreams;
numCodersOutStreams += numCoders; numCodersOutStreams += numCoders;
folders.FoStartPackStreamIndex[fo] = packStreamIndex; folders.FoStartPackStreamIndex[fo] = packStreamIndex;
if (numPackStreams > folders.NumPackStreams - packStreamIndex)
ThrowIncorrect();
packStreamIndex += numPackStreams; packStreamIndex += numPackStreams;
folders.FoToMainUnpackSizeIndex[fo] = (Byte)indexOfMainStream; folders.FoToMainUnpackSizeIndex[fo] = (Byte)indexOfMainStream;
} }
@ -770,6 +774,8 @@ void CInArchive::ReadUnpackInfo(
folders.FoStartPackStreamIndex[fo] = packStreamIndex; folders.FoStartPackStreamIndex[fo] = packStreamIndex;
folders.FoCodersDataOffset[fo] = _inByteBack->GetPtr() - startBufPtr; folders.FoCodersDataOffset[fo] = _inByteBack->GetPtr() - startBufPtr;
folders.CodersData.CopyFrom(startBufPtr, dataSize); folders.CodersData.CopyFrom(startBufPtr, dataSize);
// if (folders.NumPackStreams != packStreamIndex) ThrowUnsupported();
} }
WaitId(NID::kCodersUnpackSize); WaitId(NID::kCodersUnpackSize);

View File

@ -380,29 +380,33 @@ static inline bool IsExeFilter(CMethodId m)
return false; return false;
} }
static unsigned Get_FilterGroup_for_Folder(CRecordVector<CFilterMode2> &filters, const CFolderEx &f) static unsigned Get_FilterGroup_for_Folder(
CRecordVector<CFilterMode2> &filters, const CFolderEx &f, bool extractFilter)
{ {
CFilterMode2 m; CFilterMode2 m;
m.Id = 0; m.Id = 0;
m.Delta = 0; m.Delta = 0;
m.Encrypted = f.IsEncrypted(); m.Encrypted = f.IsEncrypted();
const CCoderInfo &coder = f.Coders[f.UnpackCoder]; if (extractFilter)
{
const CCoderInfo &coder = f.Coders[f.UnpackCoder];
if (coder.MethodID == k_Delta) if (coder.MethodID == k_Delta)
{
if (coder.Props.Size() == 1)
{ {
m.Delta = (unsigned)coder.Props[0] + 1; if (coder.Props.Size() == 1)
m.Id = k_Delta; {
m.Delta = (unsigned)coder.Props[0] + 1;
m.Id = k_Delta;
}
}
else if (IsExeFilter(coder.MethodID))
{
m.Id = (UInt32)coder.MethodID;
if (m.Id == k_BCJ2)
m.Id = k_BCJ;
m.SetDelta();
} }
}
else if (IsExeFilter(coder.MethodID))
{
m.Id = (UInt32)coder.MethodID;
if (m.Id == k_BCJ2)
m.Id = k_BCJ;
m.SetDelta();
} }
return GetGroup(filters, m); return GetGroup(filters, m);
@ -1577,7 +1581,7 @@ HRESULT Update(
return E_NOTIMPL; return E_NOTIMPL;
*/ */
UInt64 startBlockSize = db != 0 ? db->ArcInfo.StartPosition: 0; UInt64 startBlockSize = db ? db->ArcInfo.StartPosition: 0;
if (startBlockSize > 0 && !options.RemoveSfxBlock) if (startBlockSize > 0 && !options.RemoveSfxBlock)
{ {
RINOK(WriteRange(inStream, seqOutStream, 0, startBlockSize, NULL)); RINOK(WriteRange(inStream, seqOutStream, 0, startBlockSize, NULL));
@ -1592,7 +1596,20 @@ HRESULT Update(
CObjectVector<CSolidGroup> groups; CObjectVector<CSolidGroup> groups;
bool thereAreRepacks = false; bool thereAreRepacks = false;
if (db != 0) bool useFilters = options.UseFilters;
if (useFilters)
{
const CCompressionMethodMode &method = *options.Method;
FOR_VECTOR (i, method.Methods)
if (IsFilterMethod(method.Methods[i].Id))
{
useFilters = false;
break;
}
}
if (db)
{ {
fileIndexToUpdateIndexMap.Alloc(db->Files.Size()); fileIndexToUpdateIndexMap.Alloc(db->Files.Size());
unsigned i; unsigned i;
@ -1638,16 +1655,18 @@ HRESULT Update(
CFolderEx f; CFolderEx f;
db->ParseFolderEx(i, f); db->ParseFolderEx(i, f);
bool isEncrypted = f.IsEncrypted(); const bool isEncrypted = f.IsEncrypted();
const bool needCopy = (numCopyItems == numUnpackStreams);
const bool extractFilter = (useFilters || needCopy);
unsigned groupIndex = Get_FilterGroup_for_Folder(filters, f); unsigned groupIndex = Get_FilterGroup_for_Folder(filters, f, extractFilter);
while (groupIndex >= groups.Size()) while (groupIndex >= groups.Size())
groups.AddNew(); groups.AddNew();
groups[groupIndex].folderRefs.Add(rep); groups[groupIndex].folderRefs.Add(rep);
if (numCopyItems == numUnpackStreams) if (needCopy)
complexity += db->GetFolderFullPackSize(i); complexity += db->GetFolderFullPackSize(i);
else else
{ {
@ -1732,22 +1751,8 @@ HRESULT Update(
// ---------- Split files to groups ---------- // ---------- Split files to groups ----------
bool useFilters = options.UseFilters;
const CCompressionMethodMode &method = *options.Method; const CCompressionMethodMode &method = *options.Method;
if (useFilters)
for (i = 0; i < method.Methods.Size(); i++)
if (IsFilterMethod(method.Methods[i].Id))
{
useFilters = false;
break;
}
/*
if (!method.Bonds.IsEmpty())
useFilters = false;
*/
for (i = 0; i < updateItems.Size(); i++) for (i = 0; i < updateItems.Size(); i++)
{ {
const CUpdateItem &ui = updateItems[i]; const CUpdateItem &ui = updateItems[i];
@ -2156,7 +2161,13 @@ HRESULT Update(
#ifndef _7ZIP_ST #ifndef _7ZIP_ST
if (options.MultiThreadMixer) if (options.MultiThreadMixer)
{ {
// 16.00: hang was fixed : for case if decoding was not finished.
// We close CBinderInStream and it calls CStreamBinder::CloseRead()
inStreamSizeCount.Release();
sbInStream.Release();
threadDecoder.WaitExecuteFinish(); threadDecoder.WaitExecuteFinish();
HRESULT decodeRes = threadDecoder.Result; HRESULT decodeRes = threadDecoder.Result;
// if (res == k_My_HRESULT_CRC_ERROR) // if (res == k_My_HRESULT_CRC_ERROR)
if (decodeRes == S_FALSE) if (decodeRes == S_FALSE)

View File

@ -110,7 +110,7 @@ HRESULT CDecoder::Create(bool filteredMode, ISequentialInStream *inStream)
{ {
_filterCoder = new CFilterCoder(false); _filterCoder = new CFilterCoder(false);
CMyComPtr<ICompressCoder> coder = _filterCoder; CMyComPtr<ICompressCoder> coder = _filterCoder;
_filterCoder->Filter = new CBcjCoder(false); _filterCoder->Filter = new NCompress::NBcj::CCoder(false);
_bcjStream = _filterCoder; _bcjStream = _filterCoder;
} }
} }

View File

@ -187,11 +187,15 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
UInt64 size; UInt64 size;
{ {
/*
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
RINOK(volumeCallback->GetProperty(kpidSize, &prop)); RINOK(volumeCallback->GetProperty(kpidSize, &prop));
if (prop.vt != VT_UI8) if (prop.vt != VT_UI8)
return E_INVALIDARG; return E_INVALIDARG;
size = prop.uhVal.QuadPart; size = prop.uhVal.QuadPart;
*/
RINOK(stream->Seek(0, STREAM_SEEK_END, &size));
RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
} }
_totalSize += size; _totalSize += size;
@ -217,11 +221,15 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
if (!stream) if (!stream)
break; break;
{ {
/*
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
RINOK(volumeCallback->GetProperty(kpidSize, &prop)); RINOK(volumeCallback->GetProperty(kpidSize, &prop));
if (prop.vt != VT_UI8) if (prop.vt != VT_UI8)
return E_INVALIDARG; return E_INVALIDARG;
size = prop.uhVal.QuadPart; size = prop.uhVal.QuadPart;
*/
RINOK(stream->Seek(0, STREAM_SEEK_END, &size));
RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
} }
_totalSize += size; _totalSize += size;
_sizes.Add(size); _sizes.Add(size);

View File

@ -10,6 +10,8 @@
#include "../../Common/Defs.h" #include "../../Common/Defs.h"
#include "../../Common/IntToString.h" #include "../../Common/IntToString.h"
#include "../../Windows/PropVariant.h"
#include "../ICoder.h" #include "../ICoder.h"
#include "../Common/CWrappers.h" #include "../Common/CWrappers.h"
@ -21,7 +23,9 @@
#include "IArchive.h" #include "IArchive.h"
#ifndef EXTRACT_ONLY
#include "Common/HandlerOut.h" #include "Common/HandlerOut.h"
#endif
#include "XzHandler.h" #include "XzHandler.h"
@ -83,15 +87,20 @@ class CHandler:
CMyComPtr<IInStream> _stream; CMyComPtr<IInStream> _stream;
CMyComPtr<ISequentialInStream> _seqStream; CMyComPtr<ISequentialInStream> _seqStream;
UInt32 _filterId;
AString _methodsString; AString _methodsString;
#ifndef EXTRACT_ONLY
UInt32 _filterId;
void Init() void Init()
{ {
_filterId = 0; _filterId = 0;
CMultiMethodProps::Init(); CMultiMethodProps::Init();
} }
#endif
HRESULT Open2(IInStream *inStream, /* UInt32 flags, */ IArchiveOpenCallback *callback); HRESULT Open2(IInStream *inStream, /* UInt32 flags, */ IArchiveOpenCallback *callback);
HRESULT Decode2(ISequentialInStream *seqInStream, ISequentialOutStream *outStream, HRESULT Decode2(ISequentialInStream *seqInStream, ISequentialOutStream *outStream,
@ -126,9 +135,12 @@ public:
CHandler::CHandler() CHandler::CHandler()
{ {
#ifndef EXTRACT_ONLY
Init(); Init();
#endif
} }
static const Byte kProps[] = static const Byte kProps[] =
{ {
kpidSize, kpidSize,

View File

@ -5,16 +5,19 @@
#include <string.h> #include <string.h>
#include "LimitedStreams.h" #include "LimitedStreams.h"
#include "../../Common/Defs.h"
STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize) STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{ {
UInt32 realProcessedSize = 0; UInt32 realProcessedSize = 0;
UInt32 sizeToRead = (UInt32)MyMin((_size - _pos), (UInt64)size);
HRESULT result = S_OK;
if (sizeToRead > 0)
{ {
result = _stream->Read(data, sizeToRead, &realProcessedSize); const UInt64 rem = _size - _pos;
if (size > rem)
size = (UInt32)rem;
}
HRESULT result = S_OK;
if (size != 0)
{
result = _stream->Read(data, size, &realProcessedSize);
_pos += realProcessedSize; _pos += realProcessedSize;
if (realProcessedSize == 0) if (realProcessedSize == 0)
_wasFinished = true; _wasFinished = true;
@ -34,9 +37,11 @@ STDMETHODIMP CLimitedInStream::Read(void *data, UInt32 size, UInt32 *processedSi
return S_OK; return S_OK;
// return (_virtPos == _size) ? S_OK: E_FAIL; // ERROR_HANDLE_EOF // return (_virtPos == _size) ? S_OK: E_FAIL; // ERROR_HANDLE_EOF
} }
UInt64 rem = _size - _virtPos; {
if (rem < size) const UInt64 rem = _size - _virtPos;
size = (UInt32)rem; if (size > rem)
size = (UInt32)rem;
}
UInt64 newPos = _startOffset + _virtPos; UInt64 newPos = _startOffset + _virtPos;
if (newPos != _physPos) if (newPos != _physPos)
{ {

View File

@ -30,6 +30,7 @@ public:
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
UInt64 GetSize() const { return _pos; } UInt64 GetSize() const { return _pos; }
UInt64 GetRem() const { return _size - _pos; }
bool WasFinished() const { return _wasFinished; } bool WasFinished() const { return _wasFinished; }
}; };

View File

@ -6,9 +6,12 @@
#include "Bcj2Coder.h" #include "Bcj2Coder.h"
REGISTER_CODEC_CREATE_2(CreateCodec, NCompress::NBcj2::CDecoder(), ICompressCoder2) namespace NCompress {
namespace NBcj2 {
REGISTER_CODEC_CREATE_2(CreateCodec, CDecoder(), ICompressCoder2)
#ifndef EXTRACT_ONLY #ifndef EXTRACT_ONLY
REGISTER_CODEC_CREATE_2(CreateCodecOut, NCompress::NBcj2::CEncoder(), ICompressCoder2) REGISTER_CODEC_CREATE_2(CreateCodecOut, CEncoder(), ICompressCoder2)
#else #else
#define CreateCodecOut NULL #define CreateCodecOut NULL
#endif #endif
@ -17,3 +20,5 @@ REGISTER_CODEC_VAR
{ CreateCodec, CreateCodecOut, 0x303011B, "BCJ2", 4, false }; { CreateCodec, CreateCodecOut, 0x303011B, "BCJ2", 4, false };
REGISTER_CODEC(BCJ2) REGISTER_CODEC(BCJ2)
}}

View File

@ -4,16 +4,21 @@
#include "BcjCoder.h" #include "BcjCoder.h"
STDMETHODIMP CBcjCoder::Init() namespace NCompress {
namespace NBcj {
STDMETHODIMP CCoder::Init()
{ {
_bufferPos = 0; _bufferPos = 0;
x86_Convert_Init(_prevMask); x86_Convert_Init(_prevMask);
return S_OK; return S_OK;
} }
STDMETHODIMP_(UInt32) CBcjCoder::Filter(Byte *data, UInt32 size) STDMETHODIMP_(UInt32) CCoder::Filter(Byte *data, UInt32 size)
{ {
UInt32 processed = (UInt32)::x86_Convert(data, size, _bufferPos, &_prevMask, _encode); UInt32 processed = (UInt32)::x86_Convert(data, size, _bufferPos, &_prevMask, _encode);
_bufferPos += processed; _bufferPos += processed;
return processed; return processed;
} }
}}

View File

@ -9,7 +9,10 @@
#include "../ICoder.h" #include "../ICoder.h"
class CBcjCoder: namespace NCompress {
namespace NBcj {
class CCoder:
public ICompressFilter, public ICompressFilter,
public CMyUnknownImp public CMyUnknownImp
{ {
@ -17,10 +20,12 @@ class CBcjCoder:
UInt32 _prevMask; UInt32 _prevMask;
int _encode; int _encode;
public: public:
MY_UNKNOWN_IMP; MY_UNKNOWN_IMP1(ICompressFilter);
INTERFACE_ICompressFilter(;) INTERFACE_ICompressFilter(;)
CBcjCoder(int encode): _bufferPos(0), _encode(encode) { x86_Convert_Init(_prevMask); } CCoder(int encode): _bufferPos(0), _encode(encode) { x86_Convert_Init(_prevMask); }
}; };
}}
#endif #endif

View File

@ -6,7 +6,12 @@
#include "BcjCoder.h" #include "BcjCoder.h"
namespace NCompress {
namespace NBcj {
REGISTER_FILTER_E(BCJ, REGISTER_FILTER_E(BCJ,
CBcjCoder(false), CCoder(false),
CBcjCoder(true), CCoder(true),
0x3030103, "BCJ") 0x3030103, "BCJ")
}}

View File

@ -4,15 +4,20 @@
#include "BranchMisc.h" #include "BranchMisc.h"
STDMETHODIMP CBranchCoder::Init() namespace NCompress {
namespace NBranch {
STDMETHODIMP CCoder::Init()
{ {
_bufferPos = 0; _bufferPos = 0;
return S_OK; return S_OK;
} }
STDMETHODIMP_(UInt32) CBranchCoder::Filter(Byte *data, UInt32 size) STDMETHODIMP_(UInt32) CCoder::Filter(Byte *data, UInt32 size)
{ {
UInt32 processed = (UInt32)BraFunc(data, size, _bufferPos, _encode); UInt32 processed = (UInt32)BraFunc(data, size, _bufferPos, _encode);
_bufferPos += processed; _bufferPos += processed;
return processed; return processed;
} }
}}

View File

@ -13,7 +13,10 @@ typedef SizeT (*Func_Bra)(Byte *data, SizeT size, UInt32 ip, int encoding);
EXTERN_C_END EXTERN_C_END
class CBranchCoder: namespace NCompress {
namespace NBranch {
class CCoder:
public ICompressFilter, public ICompressFilter,
public CMyUnknownImp public CMyUnknownImp
{ {
@ -21,10 +24,12 @@ class CBranchCoder:
int _encode; int _encode;
Func_Bra BraFunc; Func_Bra BraFunc;
public: public:
MY_UNKNOWN_IMP; MY_UNKNOWN_IMP1(ICompressFilter);
INTERFACE_ICompressFilter(;) INTERFACE_ICompressFilter(;)
CBranchCoder(Func_Bra bra, int encode): _bufferPos(0), _encode(encode), BraFunc(bra) {} CCoder(Func_Bra bra, int encode): _bufferPos(0), _encode(encode), BraFunc(bra) {}
}; };
}}
#endif #endif

View File

@ -8,9 +8,12 @@
#include "BranchMisc.h" #include "BranchMisc.h"
namespace NCompress {
namespace NBranch {
#define CREATE_BRA(n) \ #define CREATE_BRA(n) \
REGISTER_FILTER_CREATE(CreateBra_Decoder_ ## n, CBranchCoder(n ## _Convert, false)) \ REGISTER_FILTER_CREATE(CreateBra_Decoder_ ## n, CCoder(n ## _Convert, false)) \
REGISTER_FILTER_CREATE(CreateBra_Encoder_ ## n, CBranchCoder(n ## _Convert, true)) \ REGISTER_FILTER_CREATE(CreateBra_Encoder_ ## n, CCoder(n ## _Convert, true)) \
CREATE_BRA(PPC) CREATE_BRA(PPC)
CREATE_BRA(IA64) CREATE_BRA(IA64)
@ -34,3 +37,5 @@ REGISTER_CODECS_VAR
}; };
REGISTER_CODECS(Branch) REGISTER_CODECS(Branch)
}}

View File

@ -8,12 +8,15 @@
#include "../Common/RegisterCodec.h" #include "../Common/RegisterCodec.h"
namespace NCompress {
namespace NByteSwap {
class CByteSwap2: class CByteSwap2:
public ICompressFilter, public ICompressFilter,
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(ICompressFilter);
INTERFACE_ICompressFilter(;) INTERFACE_ICompressFilter(;)
}; };
@ -22,7 +25,7 @@ class CByteSwap4:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(ICompressFilter);
INTERFACE_ICompressFilter(;) INTERFACE_ICompressFilter(;)
}; };
@ -85,3 +88,5 @@ REGISTER_CODECS_VAR
}; };
REGISTER_CODECS(ByteSwap) REGISTER_CODECS(ByteSwap)
}}

View File

@ -6,6 +6,10 @@
#include "CopyCoder.h" #include "CopyCoder.h"
REGISTER_CODEC_CREATE(CreateCodec, NCompress::CCopyCoder()) namespace NCompress {
REGISTER_CODEC_CREATE(CreateCodec, CCopyCoder())
REGISTER_CODEC_2(Copy, CreateCodec, CreateCodec, 0, "Copy") REGISTER_CODEC_2(Copy, CreateCodec, CreateCodec, 0, "Copy")
}

View File

@ -10,6 +10,9 @@
#include "../Common/RegisterCodec.h" #include "../Common/RegisterCodec.h"
namespace NCompress {
namespace NDelta {
struct CDelta struct CDelta
{ {
unsigned _delta; unsigned _delta;
@ -22,7 +25,7 @@ struct CDelta
#ifndef EXTRACT_ONLY #ifndef EXTRACT_ONLY
class CDeltaEncoder: class CEncoder:
public ICompressFilter, public ICompressFilter,
public ICompressSetCoderProperties, public ICompressSetCoderProperties,
public ICompressWriteCoderProperties, public ICompressWriteCoderProperties,
@ -30,25 +33,25 @@ class CDeltaEncoder:
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP2(ICompressSetCoderProperties, ICompressWriteCoderProperties) MY_UNKNOWN_IMP3(ICompressFilter, ICompressSetCoderProperties, ICompressWriteCoderProperties)
INTERFACE_ICompressFilter(;) INTERFACE_ICompressFilter(;)
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream); STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
}; };
STDMETHODIMP CDeltaEncoder::Init() STDMETHODIMP CEncoder::Init()
{ {
DeltaInit(); DeltaInit();
return S_OK; return S_OK;
} }
STDMETHODIMP_(UInt32) CDeltaEncoder::Filter(Byte *data, UInt32 size) STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
{ {
Delta_Encode(_state, _delta, data, size); Delta_Encode(_state, _delta, data, size);
return size; return size;
} }
STDMETHODIMP CDeltaEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps) STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
{ {
UInt32 delta = _delta; UInt32 delta = _delta;
for (UInt32 i = 0; i < numProps; i++) for (UInt32 i = 0; i < numProps; i++)
@ -75,7 +78,7 @@ STDMETHODIMP CDeltaEncoder::SetCoderProperties(const PROPID *propIDs, const PROP
return S_OK; return S_OK;
} }
STDMETHODIMP CDeltaEncoder::WriteCoderProperties(ISequentialOutStream *outStream) STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
{ {
Byte prop = (Byte)(_delta - 1); Byte prop = (Byte)(_delta - 1);
return outStream->Write(&prop, 1, NULL); return outStream->Write(&prop, 1, NULL);
@ -84,31 +87,31 @@ STDMETHODIMP CDeltaEncoder::WriteCoderProperties(ISequentialOutStream *outStream
#endif #endif
class CDeltaDecoder: class CDecoder:
public ICompressFilter, public ICompressFilter,
public ICompressSetDecoderProperties2, public ICompressSetDecoderProperties2,
CDelta, CDelta,
public CMyUnknownImp public CMyUnknownImp
{ {
public: public:
MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2) MY_UNKNOWN_IMP2(ICompressFilter, ICompressSetDecoderProperties2)
INTERFACE_ICompressFilter(;) INTERFACE_ICompressFilter(;)
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size); STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
}; };
STDMETHODIMP CDeltaDecoder::Init() STDMETHODIMP CDecoder::Init()
{ {
DeltaInit(); DeltaInit();
return S_OK; return S_OK;
} }
STDMETHODIMP_(UInt32) CDeltaDecoder::Filter(Byte *data, UInt32 size) STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
{ {
Delta_Decode(_state, _delta, data, size); Delta_Decode(_state, _delta, data, size);
return size; return size;
} }
STDMETHODIMP CDeltaDecoder::SetDecoderProperties2(const Byte *props, UInt32 size) STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *props, UInt32 size)
{ {
if (size != 1) if (size != 1)
return E_INVALIDARG; return E_INVALIDARG;
@ -118,6 +121,8 @@ STDMETHODIMP CDeltaDecoder::SetDecoderProperties2(const Byte *props, UInt32 size
REGISTER_FILTER_E(Delta, REGISTER_FILTER_E(Delta,
CDeltaDecoder(), CDecoder(),
CDeltaEncoder(), CEncoder(),
3, "Delta") 3, "Delta")
}}

View File

@ -20,7 +20,7 @@ class CEncoder:
{ {
CLzma2EncHandle _encoder; CLzma2EncHandle _encoder;
public: public:
MY_UNKNOWN_IMP2(ICompressSetCoderProperties, ICompressWriteCoderProperties) MY_UNKNOWN_IMP3(ICompressCoder, ICompressSetCoderProperties, ICompressWriteCoderProperties)
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);

View File

@ -10,8 +10,13 @@
#include "Lzma2Encoder.h" #include "Lzma2Encoder.h"
#endif #endif
namespace NCompress {
namespace NLzma2 {
REGISTER_CODEC_E(LZMA2, REGISTER_CODEC_E(LZMA2,
NCompress::NLzma2::CDecoder(), CDecoder(),
NCompress::NLzma2::CEncoder(), CEncoder(),
0x21, 0x21,
"LZMA2") "LZMA2")
}}

View File

@ -21,7 +21,7 @@ class CEncoder:
CLzmaEncHandle _encoder; CLzmaEncHandle _encoder;
UInt64 _inputProcessed; UInt64 _inputProcessed;
public: public:
MY_UNKNOWN_IMP2(ICompressSetCoderProperties, ICompressWriteCoderProperties) MY_UNKNOWN_IMP3(ICompressCoder, ICompressSetCoderProperties, ICompressWriteCoderProperties)
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);

View File

@ -10,8 +10,13 @@
#include "LzmaEncoder.h" #include "LzmaEncoder.h"
#endif #endif
namespace NCompress {
namespace NLzma {
REGISTER_CODEC_E(LZMA, REGISTER_CODEC_E(LZMA,
NCompress::NLzma::CDecoder(), CDecoder(),
NCompress::NLzma::CEncoder(), CEncoder(),
0x30101, 0x30101,
"LZMA") "LZMA")
}}

View File

@ -41,7 +41,8 @@ class CEncoder :
CPpmd7 _ppmd; CPpmd7 _ppmd;
CEncProps _props; CEncProps _props;
public: public:
MY_UNKNOWN_IMP2( MY_UNKNOWN_IMP3(
ICompressCoder,
ICompressSetCoderProperties, ICompressSetCoderProperties,
ICompressWriteCoderProperties) ICompressWriteCoderProperties)
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,

View File

@ -10,8 +10,13 @@
#include "PpmdEncoder.h" #include "PpmdEncoder.h"
#endif #endif
namespace NCompress {
namespace NPpmd {
REGISTER_CODEC_E(PPMD, REGISTER_CODEC_E(PPMD,
NCompress::NPpmd::CDecoder(), CDecoder(),
NCompress::NPpmd::CEncoder(), CEncoder(),
0x30401, 0x30401,
"PPMD") "PPMD")
}}

View File

@ -86,7 +86,8 @@ class CEncoder:
public ICryptoResetInitVector public ICryptoResetInitVector
{ {
public: public:
MY_UNKNOWN_IMP3( MY_UNKNOWN_IMP4(
ICompressFilter,
ICryptoSetPassword, ICryptoSetPassword,
ICompressWriteCoderProperties, ICompressWriteCoderProperties,
// ICryptoResetSalt, // ICryptoResetSalt,
@ -104,7 +105,8 @@ class CDecoder:
public ICompressSetDecoderProperties2 public ICompressSetDecoderProperties2
{ {
public: public:
MY_UNKNOWN_IMP2( MY_UNKNOWN_IMP3(
ICompressFilter,
ICryptoSetPassword, ICryptoSetPassword,
ICompressSetDecoderProperties2) ICompressSetDecoderProperties2)
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size); STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);

View File

@ -6,7 +6,12 @@
#include "7zAes.h" #include "7zAes.h"
namespace NCrypto {
namespace N7z {
REGISTER_FILTER_E(7zAES, REGISTER_FILTER_E(7zAES,
NCrypto::N7z::CDecoder(), CDecoder(),
NCrypto::N7z::CEncoder(), CEncoder(),
0x6F10701, "7zAES") 0x6F10701, "7zAES")
}}

View File

@ -30,7 +30,7 @@ class CAesCbcCoder:
public: public:
CAesCbcCoder(bool encodeMode, unsigned keySize); CAesCbcCoder(bool encodeMode, unsigned keySize);
MY_UNKNOWN_IMP2(ICryptoProperties, ICompressSetCoderProperties) MY_UNKNOWN_IMP3(ICompressFilter, ICryptoProperties, ICompressSetCoderProperties)
INTERFACE_ICompressFilter(;) INTERFACE_ICompressFilter(;)

View File

@ -6,7 +6,11 @@
#include "MyAes.h" #include "MyAes.h"
namespace NCrypto {
REGISTER_FILTER_E(AES256CBC, REGISTER_FILTER_E(AES256CBC,
NCrypto::CAesCbcDecoder(32), CAesCbcDecoder(32),
NCrypto::CAesCbcEncoder(32), CAesCbcEncoder(32),
0x6F00181, "AES256CBC") 0x6F00181, "AES256CBC")
}

View File

@ -1053,7 +1053,7 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings; const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
unsigned numNonSwitchStrings = nonSwitchStrings.Size(); unsigned numNonSwitchStrings = nonSwitchStrings.Size();
if (numNonSwitchStrings < kMinNonSwitchWords) if (numNonSwitchStrings < kMinNonSwitchWords)
throw CArcCmdLineException("The command must be spcified"); throw CArcCmdLineException("The command must be specified");
if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], options.Command)) if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], options.Command))
throw CArcCmdLineException("Unsupported command:", nonSwitchStrings[kCommandIndex]); throw CArcCmdLineException("Unsupported command:", nonSwitchStrings[kCommandIndex]);

View File

@ -43,6 +43,7 @@ STDMETHODIMP COpenCallbackImp::GetProperty(PROPID propID, PROPVARIANT *value)
switch (propID) switch (propID)
{ {
case kpidName: prop = _subArchiveName; break; case kpidName: prop = _subArchiveName; break;
// case kpidSize: prop = _subArchiveSize; break; // we don't use it now
} }
else else
switch (propID) switch (propID)

View File

@ -1632,6 +1632,36 @@ HRESULT CArc::OpenStream2(const COpenOptions &op)
#endif #endif
{ {
#ifndef _SFX
bool isZip = false;
bool isRar = false;
const wchar_t c = extension[0];
if (c == 'z' || c == 'Z' || c == 'r' || c == 'R')
{
bool isNumber = false;
for (unsigned k = 1;; k++)
{
const wchar_t d = extension[k];
if (d == 0)
break;
if (d < '0' || d > '9')
{
isNumber = false;
break;
}
isNumber = true;
}
if (isNumber)
if (c == 'z' || c == 'Z')
isZip = true;
else
isRar = true;
}
#endif
FOR_VECTOR (i, op.codecs->Formats) FOR_VECTOR (i, op.codecs->Formats)
{ {
const CArcInfoEx &ai = op.codecs->Formats[i]; const CArcInfoEx &ai = op.codecs->Formats[i];
@ -1647,7 +1677,12 @@ HRESULT CArc::OpenStream2(const COpenOptions &op)
isPrearcExt = true; isPrearcExt = true;
#endif #endif
if (ai.FindExtension(extension) >= 0) if (ai.FindExtension(extension) >= 0
#ifndef _SFX
|| isZip && StringsAreEqualNoCase_Ascii(ai.Name, "zip")
|| isRar && StringsAreEqualNoCase_Ascii(ai.Name, "rar")
#endif
)
{ {
// PrintNumber("orderIndices.Insert", i); // PrintNumber("orderIndices.Insert", i);
orderIndices.Insert(numFinded++, i); orderIndices.Insert(numFinded++, i);

View File

@ -34,7 +34,7 @@ class CCrcHasher:
public: public:
CCrcHasher(): _crc(CRC_INIT_VAL) { SetFunctions(0); } CCrcHasher(): _crc(CRC_INIT_VAL) { SetFunctions(0); }
MY_UNKNOWN_IMP1(ICompressSetCoderProperties) MY_UNKNOWN_IMP2(IHasher, ICompressSetCoderProperties)
INTERFACE_IHasher(;) INTERFACE_IHasher(;)
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
}; };

View File

@ -18,7 +18,7 @@ class CSha256Hasher:
public: public:
CSha256Hasher() { Sha256_Init(&_sha); } CSha256Hasher() { Sha256_Init(&_sha); }
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IHasher)
INTERFACE_IHasher(;) INTERFACE_IHasher(;)
}; };

View File

@ -19,7 +19,7 @@ class CXzCrc64Hasher:
public: public:
CXzCrc64Hasher(): _crc(CRC64_INIT_VAL) {} CXzCrc64Hasher(): _crc(CRC64_INIT_VAL) {}
MY_UNKNOWN_IMP MY_UNKNOWN_IMP1(IHasher)
INTERFACE_IHasher(;) INTERFACE_IHasher(;)
}; };

View File

@ -1,6 +1,11 @@
HISTORY of the LZMA SDK HISTORY of the LZMA SDK
----------------------- -----------------------
16.00 2016-05-10
-------------------------
- Some bugs were fixed,
15.12 2015-11-19 15.12 2015-11-19
------------------------- -------------------------
- The BUG in C version of 7z decoder was fixed: - The BUG in C version of 7z decoder was fixed:

View File

@ -1,4 +1,4 @@
LZMA SDK 15.14 LZMA SDK 16.00
-------------- --------------
LZMA SDK provides the documentation, samples, header files, LZMA SDK provides the documentation, samples, header files,