mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 12:07:03 -06:00
23.01
This commit is contained in:
@@ -43,7 +43,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "Z7_EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
@@ -53,7 +53,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-zip\Formats\7z.dll" /opt:NOWIN98
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Util\Formats\7z.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "7z - Win32 Debug"
|
||||
@@ -70,7 +70,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "Z7_EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
@@ -80,7 +80,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-zip\Formats\7z.dll" /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Util\Formats\7z.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -101,7 +101,11 @@ SOURCE=..\ArchiveExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\DllExports.cpp
|
||||
SOURCE=..\..\Compress\CodecExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\DllExports2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -514,14 +518,6 @@ SOURCE=..\..\Common\VirtThread.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileDir.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 7zCompressionMode.h
|
||||
|
||||
#ifndef __7Z_COMPRESSION_MODE_H
|
||||
#define __7Z_COMPRESSION_MODE_H
|
||||
#ifndef ZIP7_INC_7Z_COMPRESSION_MODE_H
|
||||
#define ZIP7_INC_7Z_COMPRESSION_MODE_H
|
||||
|
||||
#include "../../Common/MethodId.h"
|
||||
#include "../../Common/MethodProps.h"
|
||||
@@ -53,7 +53,7 @@ struct CCompressionMethodMode
|
||||
bool DefaultMethod_was_Inserted;
|
||||
bool Filter_was_Inserted;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
UInt32 NumThreads;
|
||||
bool NumThreads_WasForced;
|
||||
bool MultiThreadMixer;
|
||||
@@ -69,7 +69,7 @@ struct CCompressionMethodMode
|
||||
CCompressionMethodMode():
|
||||
DefaultMethod_was_Inserted(false)
|
||||
, Filter_was_Inserted(false)
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
, NumThreads(1)
|
||||
, NumThreads_WasForced(false)
|
||||
, MultiThreadMixer(true)
|
||||
@@ -79,6 +79,10 @@ struct CCompressionMethodMode
|
||||
, PasswordIsDefined(false)
|
||||
{}
|
||||
|
||||
#ifdef Z7_CPP_IS_SUPPORTED_default
|
||||
CCompressionMethodMode(const CCompressionMethodMode &) = default;
|
||||
CCompressionMethodMode& operator =(const CCompressionMethodMode &) = default;
|
||||
#endif
|
||||
~CCompressionMethodMode() { Password.Wipe_and_Empty(); }
|
||||
};
|
||||
|
||||
|
||||
@@ -5,25 +5,23 @@
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/StreamObjects.h"
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "7zDecode.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
class CDecProgress:
|
||||
public ICompressProgressInfo,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CDecProgress
|
||||
, ICompressProgressInfo
|
||||
)
|
||||
CMyComPtr<ICompressProgressInfo> _progress;
|
||||
public:
|
||||
CDecProgress(ICompressProgressInfo *progress): _progress(progress) {}
|
||||
|
||||
MY_UNKNOWN_IMP1(ICompressProgressInfo)
|
||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
||||
};
|
||||
|
||||
STDMETHODIMP CDecProgress::SetRatioInfo(const UInt64 * /* inSize */, const UInt64 *outSize)
|
||||
Z7_COM7F_IMF(CDecProgress::SetRatioInfo(const UInt64 * /* inSize */, const UInt64 *outSize))
|
||||
{
|
||||
return _progress->SetRatioInfo(NULL, outSize);
|
||||
}
|
||||
@@ -110,20 +108,23 @@ static bool AreBindInfoExEqual(const CBindInfoEx &a1, const CBindInfoEx &a2)
|
||||
}
|
||||
|
||||
CDecoder::CDecoder(bool useMixerMT):
|
||||
_bindInfoPrev_Defined(false),
|
||||
_useMixerMT(useMixerMT)
|
||||
{}
|
||||
|
||||
|
||||
struct CLockedInStream:
|
||||
public IUnknown,
|
||||
public CMyUnknownImp
|
||||
_bindInfoPrev_Defined(false)
|
||||
{
|
||||
#if defined(USE_MIXER_ST) && defined(USE_MIXER_MT)
|
||||
_useMixerMT = useMixerMT;
|
||||
#else
|
||||
UNUSED_VAR(useMixerMT)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Z7_CLASS_IMP_COM_0(
|
||||
CLockedInStream
|
||||
)
|
||||
public:
|
||||
CMyComPtr<IInStream> Stream;
|
||||
UInt64 Pos;
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
#ifdef USE_MIXER_MT
|
||||
NWindows::NSynchronization::CCriticalSection CriticalSection;
|
||||
#endif
|
||||
@@ -132,10 +133,10 @@ struct CLockedInStream:
|
||||
|
||||
#ifdef USE_MIXER_MT
|
||||
|
||||
class CLockedSequentialInStreamMT:
|
||||
public ISequentialInStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CLockedSequentialInStreamMT
|
||||
, ISequentialInStream
|
||||
)
|
||||
CLockedInStream *_glob;
|
||||
UInt64 _pos;
|
||||
CMyComPtr<IUnknown> _globRef;
|
||||
@@ -146,24 +147,20 @@ public:
|
||||
_glob = lockedInStream;
|
||||
_pos = startPos;
|
||||
}
|
||||
|
||||
MY_UNKNOWN_IMP1(ISequentialInStream)
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
|
||||
STDMETHODIMP CLockedSequentialInStreamMT::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CLockedSequentialInStreamMT::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(_glob->CriticalSection);
|
||||
|
||||
if (_pos != _glob->Pos)
|
||||
{
|
||||
RINOK(_glob->Stream->Seek((Int64)_pos, STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(_glob->Stream, _pos))
|
||||
_glob->Pos = _pos;
|
||||
}
|
||||
|
||||
UInt32 realProcessedSize = 0;
|
||||
HRESULT res = _glob->Stream->Read(data, size, &realProcessedSize);
|
||||
const HRESULT res = _glob->Stream->Read(data, size, &realProcessedSize);
|
||||
_pos += realProcessedSize;
|
||||
_glob->Pos = _pos;
|
||||
if (processedSize)
|
||||
@@ -176,10 +173,10 @@ STDMETHODIMP CLockedSequentialInStreamMT::Read(void *data, UInt32 size, UInt32 *
|
||||
|
||||
#ifdef USE_MIXER_ST
|
||||
|
||||
class CLockedSequentialInStreamST:
|
||||
public ISequentialInStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CLockedSequentialInStreamST
|
||||
, ISequentialInStream
|
||||
)
|
||||
CLockedInStream *_glob;
|
||||
UInt64 _pos;
|
||||
CMyComPtr<IUnknown> _globRef;
|
||||
@@ -190,22 +187,18 @@ public:
|
||||
_glob = lockedInStream;
|
||||
_pos = startPos;
|
||||
}
|
||||
|
||||
MY_UNKNOWN_IMP1(ISequentialInStream)
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
|
||||
STDMETHODIMP CLockedSequentialInStreamST::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CLockedSequentialInStreamST::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
if (_pos != _glob->Pos)
|
||||
{
|
||||
RINOK(_glob->Stream->Seek((Int64)_pos, STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(_glob->Stream, _pos))
|
||||
_glob->Pos = _pos;
|
||||
}
|
||||
|
||||
UInt32 realProcessedSize = 0;
|
||||
HRESULT res = _glob->Stream->Read(data, size, &realProcessedSize);
|
||||
const HRESULT res = _glob->Stream->Read(data, size, &realProcessedSize);
|
||||
_pos += realProcessedSize;
|
||||
_glob->Pos = _pos;
|
||||
if (processedSize)
|
||||
@@ -234,9 +227,9 @@ HRESULT CDecoder::Decode(
|
||||
|
||||
, bool &dataAfterEnd_Error
|
||||
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
|
||||
#if !defined(_7ZIP_ST)
|
||||
#if !defined(Z7_ST)
|
||||
, bool mtMode, UInt32 numThreads, UInt64 memUsage
|
||||
#endif
|
||||
)
|
||||
@@ -268,7 +261,7 @@ HRESULT CDecoder::Decode(
|
||||
We don't need to init isEncrypted and passwordIsDefined
|
||||
We must upgrade them only
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
isEncrypted = false;
|
||||
passwordIsDefined = false;
|
||||
#endif
|
||||
@@ -300,13 +293,13 @@ HRESULT CDecoder::Decode(
|
||||
#endif
|
||||
}
|
||||
|
||||
RINOK(_mixer->SetBindInfo(bindInfo));
|
||||
RINOK(_mixer->SetBindInfo(bindInfo))
|
||||
|
||||
FOR_VECTOR(i, folderInfo.Coders)
|
||||
{
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
// we don't support RAR codecs here
|
||||
if ((coderInfo.MethodID >> 8) == 0x403)
|
||||
return E_NOTIMPL;
|
||||
@@ -315,7 +308,7 @@ HRESULT CDecoder::Decode(
|
||||
CCreatedCoder cod;
|
||||
RINOK(CreateCoder_Id(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
coderInfo.MethodID, false, cod));
|
||||
coderInfo.MethodID, false, cod))
|
||||
|
||||
if (coderInfo.IsSimpleCoder())
|
||||
{
|
||||
@@ -333,13 +326,13 @@ HRESULT CDecoder::Decode(
|
||||
|
||||
// now there is no codec that uses another external codec
|
||||
/*
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
|
||||
decoderUnknown.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
|
||||
if (setCompressCodecsInfo)
|
||||
{
|
||||
// we must use g_ExternalCodecs also
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(__externalCodecs->GetCodecs));
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(_externalCodecs->GetCodecs));
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
@@ -349,14 +342,14 @@ HRESULT CDecoder::Decode(
|
||||
_bindInfoPrev_Defined = true;
|
||||
}
|
||||
|
||||
RINOK(_mixer->ReInit2());
|
||||
RINOK(_mixer->ReInit2())
|
||||
|
||||
UInt32 packStreamIndex = 0;
|
||||
UInt32 unpackStreamIndexStart = folders.FoToCoderUnpackSizes[folderIndex];
|
||||
|
||||
unsigned i;
|
||||
|
||||
#if !defined(_7ZIP_ST)
|
||||
#if !defined(Z7_ST)
|
||||
bool mt_wasUsed = false;
|
||||
#endif
|
||||
|
||||
@@ -365,59 +358,81 @@ HRESULT CDecoder::Decode(
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
IUnknown *decoder = _mixer->GetCoder(i).GetUnknown();
|
||||
|
||||
#if !defined(_7ZIP_ST)
|
||||
// now there is no codec that uses another external codec
|
||||
/*
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
{
|
||||
Z7_DECL_CMyComPtr_QI_FROM(ISetCompressCodecsInfo,
|
||||
setCompressCodecsInfo, decoder)
|
||||
if (setCompressCodecsInfo)
|
||||
{
|
||||
// we must use g_ExternalCodecs also
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(_externalCodecs->GetCodecs))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
#if !defined(Z7_ST)
|
||||
if (!mt_wasUsed)
|
||||
{
|
||||
if (mtMode)
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
||||
decoder->QueryInterface(IID_ICompressSetCoderMt, (void **)&setCoderMt);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(ICompressSetCoderMt,
|
||||
setCoderMt, decoder)
|
||||
if (setCoderMt)
|
||||
{
|
||||
mt_wasUsed = true;
|
||||
RINOK(setCoderMt->SetNumberOfThreads(numThreads));
|
||||
RINOK(setCoderMt->SetNumberOfThreads(numThreads))
|
||||
}
|
||||
}
|
||||
// if (memUsage != 0)
|
||||
{
|
||||
CMyComPtr<ICompressSetMemLimit> setMemLimit;
|
||||
decoder->QueryInterface(IID_ICompressSetMemLimit, (void **)&setMemLimit);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(ICompressSetMemLimit,
|
||||
setMemLimit, decoder)
|
||||
if (setMemLimit)
|
||||
{
|
||||
mt_wasUsed = true;
|
||||
RINOK(setMemLimit->SetMemLimit(memUsage));
|
||||
RINOK(setMemLimit->SetMemLimit(memUsage))
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
|
||||
decoder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
ICompressSetDecoderProperties2,
|
||||
setDecoderProperties, decoder)
|
||||
const CByteBuffer &props = coderInfo.Props;
|
||||
const UInt32 size32 = (UInt32)props.Size();
|
||||
if (props.Size() != size32)
|
||||
return E_NOTIMPL;
|
||||
if (setDecoderProperties)
|
||||
{
|
||||
const CByteBuffer &props = coderInfo.Props;
|
||||
const UInt32 size32 = (UInt32)props.Size();
|
||||
if (props.Size() != size32)
|
||||
return E_NOTIMPL;
|
||||
HRESULT res = setDecoderProperties->SetDecoderProperties2((const Byte *)props, size32);
|
||||
if (res == E_INVALIDARG)
|
||||
res = E_NOTIMPL;
|
||||
RINOK(res);
|
||||
RINOK(res)
|
||||
}
|
||||
else if (size32 != 0)
|
||||
{
|
||||
// v23: we fail, if decoder doesn't support properties
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
{
|
||||
CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
|
||||
decoder->QueryInterface(IID_ICryptoSetPassword, (void **)&cryptoSetPassword);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
ICryptoSetPassword,
|
||||
cryptoSetPassword, decoder)
|
||||
if (cryptoSetPassword)
|
||||
{
|
||||
isEncrypted = true;
|
||||
if (!getTextPassword)
|
||||
return E_NOTIMPL;
|
||||
CMyComBSTR_Wipe passwordBSTR;
|
||||
RINOK(getTextPassword->CryptoGetTextPassword(&passwordBSTR));
|
||||
RINOK(getTextPassword->CryptoGetTextPassword(&passwordBSTR))
|
||||
passwordIsDefined = true;
|
||||
password.Wipe_and_Empty();
|
||||
size_t len = 0;
|
||||
@@ -429,23 +444,24 @@ HRESULT CDecoder::Decode(
|
||||
CByteBuffer_Wipe buffer(len * 2);
|
||||
for (size_t k = 0; k < len; k++)
|
||||
{
|
||||
wchar_t c = passwordBSTR[k];
|
||||
const wchar_t c = passwordBSTR[k];
|
||||
((Byte *)buffer)[k * 2] = (Byte)c;
|
||||
((Byte *)buffer)[k * 2 + 1] = (Byte)(c >> 8);
|
||||
}
|
||||
RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, (UInt32)buffer.Size()));
|
||||
RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, (UInt32)buffer.Size()))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool finishMode = false;
|
||||
{
|
||||
CMyComPtr<ICompressSetFinishMode> setFinishMode;
|
||||
decoder->QueryInterface(IID_ICompressSetFinishMode, (void **)&setFinishMode);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
ICompressSetFinishMode,
|
||||
setFinishMode, decoder)
|
||||
if (setFinishMode)
|
||||
{
|
||||
finishMode = fullUnpack;
|
||||
RINOK(setFinishMode->SetFinishMode(BoolToUInt(finishMode)));
|
||||
RINOK(setFinishMode->SetFinishMode(BoolToUInt(finishMode)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,8 +513,8 @@ HRESULT CDecoder::Decode(
|
||||
if (folderInfo.PackStreams.Size() > 1)
|
||||
{
|
||||
// lockedInStream.Pos = (UInt64)(Int64)-1;
|
||||
// RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &lockedInStream.Pos));
|
||||
RINOK(inStream->Seek((Int64)(startPos + packPositions[0]), STREAM_SEEK_SET, &lockedInStreamSpec->Pos));
|
||||
// RINOK(InStream_GetPos(inStream, lockedInStream.Pos))
|
||||
RINOK(inStream->Seek((Int64)(startPos + packPositions[0]), STREAM_SEEK_SET, &lockedInStreamSpec->Pos))
|
||||
lockedInStreamSpec->Stream = inStream;
|
||||
|
||||
#ifdef USE_MIXER_MT
|
||||
@@ -523,7 +539,7 @@ HRESULT CDecoder::Decode(
|
||||
|
||||
if (folderInfo.PackStreams.Size() == 1)
|
||||
{
|
||||
RINOK(inStream->Seek((Int64)packPos, STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(inStream, packPos))
|
||||
packStream = inStream;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 7zDecode.h
|
||||
|
||||
#ifndef __7Z_DECODE_H
|
||||
#define __7Z_DECODE_H
|
||||
#ifndef ZIP7_INC_7Z_DECODE_H
|
||||
#define ZIP7_INC_7Z_DECODE_H
|
||||
|
||||
#include "../Common/CoderMixer2.h"
|
||||
|
||||
@@ -24,10 +24,13 @@ struct CBindInfoEx: public NCoderMixer2::CBindInfo
|
||||
class CDecoder
|
||||
{
|
||||
bool _bindInfoPrev_Defined;
|
||||
#ifdef USE_MIXER_ST
|
||||
#ifdef USE_MIXER_MT
|
||||
bool _useMixerMT;
|
||||
#endif
|
||||
#endif
|
||||
CBindInfoEx _bindInfoPrev;
|
||||
|
||||
bool _useMixerMT;
|
||||
|
||||
#ifdef USE_MIXER_ST
|
||||
NCoderMixer2::CMixerST *_mixerST;
|
||||
#endif
|
||||
@@ -57,9 +60,9 @@ public:
|
||||
, ISequentialInStream **inStreamMainRes
|
||||
, bool &dataAfterEnd_Error
|
||||
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
|
||||
#if !defined(_7ZIP_ST)
|
||||
#if !defined(Z7_ST)
|
||||
, bool mtMode, UInt32 numThreads, UInt64 memUsage
|
||||
#endif
|
||||
);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/ComTry.h"
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../Common/FilterCoder.h"
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
@@ -19,11 +21,11 @@ void CEncoder::InitBindConv()
|
||||
{
|
||||
unsigned numIn = _bindInfo.Coders.Size();
|
||||
|
||||
_SrcIn_to_DestOut.ClearAndSetSize(numIn);
|
||||
_DestOut_to_SrcIn.ClearAndSetSize(numIn);
|
||||
SrcIn_to_DestOut.ClearAndSetSize(numIn);
|
||||
DestOut_to_SrcIn.ClearAndSetSize(numIn);
|
||||
|
||||
unsigned numOut = _bindInfo.GetNum_Bonds_and_PackStreams();
|
||||
_SrcOut_to_DestIn.ClearAndSetSize(numOut);
|
||||
SrcOut_to_DestIn.ClearAndSetSize(numOut);
|
||||
// _DestIn_to_SrcOut.ClearAndSetSize(numOut);
|
||||
|
||||
UInt32 destIn = 0;
|
||||
@@ -38,15 +40,15 @@ void CEncoder::InitBindConv()
|
||||
numIn--;
|
||||
numOut -= coder.NumStreams;
|
||||
|
||||
_SrcIn_to_DestOut[numIn] = destOut;
|
||||
_DestOut_to_SrcIn[destOut] = numIn;
|
||||
SrcIn_to_DestOut[numIn] = destOut;
|
||||
DestOut_to_SrcIn[destOut] = numIn;
|
||||
|
||||
destOut++;
|
||||
|
||||
for (UInt32 j = 0; j < coder.NumStreams; j++, destIn++)
|
||||
{
|
||||
UInt32 index = numOut + j;
|
||||
_SrcOut_to_DestIn[index] = destIn;
|
||||
SrcOut_to_DestIn[index] = destIn;
|
||||
// _DestIn_to_SrcOut[destIn] = index;
|
||||
}
|
||||
}
|
||||
@@ -62,8 +64,8 @@ void CEncoder::SetFolder(CFolder &folder)
|
||||
{
|
||||
CBond &fb = folder.Bonds[i];
|
||||
const NCoderMixer2::CBond &mixerBond = _bindInfo.Bonds[_bindInfo.Bonds.Size() - 1 - i];
|
||||
fb.PackIndex = _SrcOut_to_DestIn[mixerBond.PackIndex];
|
||||
fb.UnpackIndex = _SrcIn_to_DestOut[mixerBond.UnpackIndex];
|
||||
fb.PackIndex = SrcOut_to_DestIn[mixerBond.PackIndex];
|
||||
fb.UnpackIndex = SrcIn_to_DestOut[mixerBond.UnpackIndex];
|
||||
}
|
||||
|
||||
folder.Coders.SetSize(_bindInfo.Coders.Size());
|
||||
@@ -81,15 +83,16 @@ void CEncoder::SetFolder(CFolder &folder)
|
||||
folder.PackStreams.SetSize(_bindInfo.PackStreams.Size());
|
||||
|
||||
for (i = 0; i < _bindInfo.PackStreams.Size(); i++)
|
||||
folder.PackStreams[i] = _SrcOut_to_DestIn[_bindInfo.PackStreams[i]];
|
||||
folder.PackStreams[i] = SrcOut_to_DestIn[_bindInfo.PackStreams[i]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
static HRESULT SetCoderProps2(const CProps &props, const UInt64 *dataSizeReduce, IUnknown *coder)
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
|
||||
coder->QueryInterface(IID_ICompressSetCoderProperties, (void **)&setCoderProperties);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
ICompressSetCoderProperties,
|
||||
setCoderProperties, coder)
|
||||
if (setCoderProperties)
|
||||
return props.SetCoderProps(setCoderProperties, dataSizeReduce);
|
||||
return props.AreThereNonOptionalProps() ? E_INVALIDARG : S_OK;
|
||||
@@ -103,11 +106,11 @@ void CMtEncMultiProgress::Init(ICompressProgressInfo *progress)
|
||||
OutSize = 0;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMtEncMultiProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 * /* outSize */)
|
||||
Z7_COM7F_IMF(CMtEncMultiProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 * /* outSize */))
|
||||
{
|
||||
UInt64 outSize2;
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
|
||||
#endif
|
||||
outSize2 = OutSize;
|
||||
@@ -146,7 +149,7 @@ HRESULT CEncoder::CreateMixerCoder(
|
||||
#endif
|
||||
}
|
||||
|
||||
RINOK(_mixer->SetBindInfo(_bindInfo));
|
||||
RINOK(_mixer->SetBindInfo(_bindInfo))
|
||||
|
||||
FOR_VECTOR (m, _options.Methods)
|
||||
{
|
||||
@@ -158,23 +161,27 @@ HRESULT CEncoder::CreateMixerCoder(
|
||||
{
|
||||
RINOK(CreateCoder_Index(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
(unsigned)methodFull.CodecIndex, true, cod));
|
||||
(unsigned)methodFull.CodecIndex, true, cod))
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(CreateCoder_Id(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
methodFull.Id, true, cod));
|
||||
methodFull.Id, true, cod))
|
||||
}
|
||||
|
||||
if (!cod.Coder && !cod.Coder2)
|
||||
{
|
||||
return E_NOTIMPL; // unsupported method, if encoder
|
||||
// return E_FAIL;
|
||||
}
|
||||
|
||||
if (cod.NumStreams != methodFull.NumStreams)
|
||||
return E_FAIL;
|
||||
if (!cod.Coder && !cod.Coder2)
|
||||
return E_FAIL;
|
||||
|
||||
CMyComPtr<IUnknown> encoderCommon = cod.Coder ? (IUnknown *)cod.Coder : (IUnknown *)cod.Coder2;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
if (methodFull.Set_NumThreads)
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
||||
@@ -184,12 +191,12 @@ HRESULT CEncoder::CreateMixerCoder(
|
||||
RINOK(setCoderMt->SetNumberOfThreads(
|
||||
/* _options.NumThreads */
|
||||
methodFull.NumThreads
|
||||
));
|
||||
))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
RINOK(SetCoderProps2(methodFull, inSizeForReduce, encoderCommon));
|
||||
RINOK(SetCoderProps2(methodFull, inSizeForReduce, encoderCommon))
|
||||
|
||||
/*
|
||||
CMyComPtr<ICryptoResetSalt> resetSalt;
|
||||
@@ -202,13 +209,13 @@ HRESULT CEncoder::CreateMixerCoder(
|
||||
|
||||
// now there is no codec that uses another external codec
|
||||
/*
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
|
||||
encoderCommon.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
|
||||
if (setCompressCodecsInfo)
|
||||
{
|
||||
// we must use g_ExternalCodecs also
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(__externalCodecs->GetCodecs));
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(_externalCodecs->GetCodecs));
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
@@ -226,7 +233,7 @@ HRESULT CEncoder::CreateMixerCoder(
|
||||
((Byte *)buffer)[i * 2] = (Byte)c;
|
||||
((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
|
||||
}
|
||||
RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, (UInt32)sizeInBytes));
|
||||
RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, (UInt32)sizeInBytes))
|
||||
}
|
||||
|
||||
_mixer->AddCoder(cod);
|
||||
@@ -236,85 +243,94 @@ HRESULT CEncoder::CreateMixerCoder(
|
||||
|
||||
|
||||
|
||||
class CSequentialOutTempBufferImp2:
|
||||
public ISequentialOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CInOutTempBuffer *_buf;
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CSequentialOutTempBufferImp2
|
||||
, ISequentialOutStream
|
||||
)
|
||||
public:
|
||||
CMtEncMultiProgress *_mtProgresSpec;
|
||||
CInOutTempBuffer TempBuffer;
|
||||
CMtEncMultiProgress *_mtProgressSpec;
|
||||
|
||||
CSequentialOutTempBufferImp2(): _buf(0), _mtProgresSpec(NULL) {}
|
||||
void Init(CInOutTempBuffer *buffer) { _buf = buffer; }
|
||||
MY_UNKNOWN_IMP1(ISequentialOutStream)
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
CSequentialOutTempBufferImp2(): _mtProgressSpec(NULL) {}
|
||||
};
|
||||
|
||||
STDMETHODIMP CSequentialOutTempBufferImp2::Write(const void *data, UInt32 size, UInt32 *processed)
|
||||
Z7_COM7F_IMF(CSequentialOutTempBufferImp2::Write(const void *data, UInt32 size, UInt32 *processed))
|
||||
{
|
||||
HRESULT res = _buf->Write_HRESULT(data, size);
|
||||
if (res != S_OK)
|
||||
{
|
||||
if (processed)
|
||||
*processed = 0;
|
||||
return res;
|
||||
}
|
||||
COM_TRY_BEGIN
|
||||
if (processed)
|
||||
*processed = 0;
|
||||
RINOK(TempBuffer.Write_HRESULT(data, size))
|
||||
if (processed)
|
||||
*processed = size;
|
||||
if (_mtProgresSpec)
|
||||
_mtProgresSpec->AddOutSize(size);
|
||||
if (_mtProgressSpec)
|
||||
_mtProgressSpec->AddOutSize(size);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
|
||||
class CSequentialOutMtNotify:
|
||||
public ISequentialOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CSequentialOutMtNotify
|
||||
, ISequentialOutStream
|
||||
)
|
||||
public:
|
||||
CMyComPtr<ISequentialOutStream> _stream;
|
||||
CMtEncMultiProgress *_mtProgresSpec;
|
||||
CMtEncMultiProgress *_mtProgressSpec;
|
||||
|
||||
CSequentialOutMtNotify(): _mtProgresSpec(NULL) {}
|
||||
MY_UNKNOWN_IMP1(ISequentialOutStream)
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
CSequentialOutMtNotify(): _mtProgressSpec(NULL) {}
|
||||
};
|
||||
|
||||
STDMETHODIMP CSequentialOutMtNotify::Write(const void *data, UInt32 size, UInt32 *processed)
|
||||
Z7_COM7F_IMF(CSequentialOutMtNotify::Write(const void *data, UInt32 size, UInt32 *processed))
|
||||
{
|
||||
UInt32 realProcessed = 0;
|
||||
HRESULT res = _stream->Write(data, size, &realProcessed);
|
||||
if (processed)
|
||||
*processed = realProcessed;
|
||||
if (_mtProgresSpec)
|
||||
_mtProgresSpec->AddOutSize(size);
|
||||
if (_mtProgressSpec)
|
||||
_mtProgressSpec->AddOutSize(size);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT FillProps_from_Coder(IUnknown *coder, CByteBuffer &props)
|
||||
{
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
ICompressWriteCoderProperties,
|
||||
writeCoderProperties, coder)
|
||||
if (writeCoderProperties)
|
||||
{
|
||||
CDynBufSeqOutStream *outStreamSpec = new CDynBufSeqOutStream;
|
||||
CMyComPtr<ISequentialOutStream> dynOutStream(outStreamSpec);
|
||||
outStreamSpec->Init();
|
||||
RINOK(writeCoderProperties->WriteCoderProperties(dynOutStream))
|
||||
outStreamSpec->CopyToBuffer(props);
|
||||
}
|
||||
else
|
||||
props.Free();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CEncoder::Encode(
|
||||
HRESULT CEncoder::Encode1(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
ISequentialInStream *inStream,
|
||||
// const UInt64 *inStreamSize,
|
||||
const UInt64 *inSizeForReduce,
|
||||
UInt64 expectedDataSize,
|
||||
CFolder &folderItem,
|
||||
CRecordVector<UInt64> &coderUnpackSizes,
|
||||
UInt64 &unpackSize,
|
||||
// CRecordVector<UInt64> &coderUnpackSizes,
|
||||
// UInt64 &unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
CRecordVector<UInt64> &packSizes,
|
||||
ICompressProgressInfo *compressProgress)
|
||||
{
|
||||
RINOK(EncoderConstr());
|
||||
RINOK(EncoderConstr())
|
||||
|
||||
if (!_mixerRef)
|
||||
{
|
||||
RINOK(CreateMixerCoder(EXTERNAL_CODECS_LOC_VARS inSizeForReduce));
|
||||
RINOK(CreateMixerCoder(EXTERNAL_CODECS_LOC_VARS inSizeForReduce))
|
||||
}
|
||||
|
||||
RINOK(_mixer->ReInit2());
|
||||
RINOK(_mixer->ReInit2())
|
||||
|
||||
CMtEncMultiProgress *mtProgressSpec = NULL;
|
||||
CMyComPtr<ICompressProgressInfo> mtProgress;
|
||||
@@ -322,30 +338,21 @@ HRESULT CEncoder::Encode(
|
||||
CSequentialOutMtNotify *mtOutStreamNotifySpec = NULL;
|
||||
CMyComPtr<ISequentialOutStream> mtOutStreamNotify;
|
||||
|
||||
CObjectVector<CInOutTempBuffer> inOutTempBuffers;
|
||||
CObjectVector<CSequentialOutTempBufferImp2 *> tempBufferSpecs;
|
||||
CRecordVector<CSequentialOutTempBufferImp2 *> tempBufferSpecs;
|
||||
CObjectVector<CMyComPtr<ISequentialOutStream> > tempBuffers;
|
||||
|
||||
unsigned numMethods = _bindInfo.Coders.Size();
|
||||
|
||||
unsigned i;
|
||||
|
||||
for (i = 1; i < _bindInfo.PackStreams.Size(); i++)
|
||||
{
|
||||
CInOutTempBuffer &iotb = inOutTempBuffers.AddNew();
|
||||
iotb.Create();
|
||||
iotb.InitWriting();
|
||||
}
|
||||
|
||||
for (i = 1; i < _bindInfo.PackStreams.Size(); i++)
|
||||
{
|
||||
CSequentialOutTempBufferImp2 *tempBufferSpec = new CSequentialOutTempBufferImp2;
|
||||
CSequentialOutTempBufferImp2 *tempBufferSpec = new CSequentialOutTempBufferImp2();
|
||||
CMyComPtr<ISequentialOutStream> tempBuffer = tempBufferSpec;
|
||||
tempBufferSpec->Init(&inOutTempBuffers[i - 1]);
|
||||
tempBuffers.Add(tempBuffer);
|
||||
tempBufferSpecs.Add(tempBufferSpec);
|
||||
tempBuffers.Add(tempBuffer);
|
||||
}
|
||||
|
||||
const unsigned numMethods = _bindInfo.Coders.Size();
|
||||
|
||||
for (i = 0; i < numMethods; i++)
|
||||
_mixer->SetCoderInfo(i, NULL, NULL, false);
|
||||
|
||||
@@ -360,15 +367,19 @@ HRESULT CEncoder::Encode(
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
CSequentialInStreamSizeCount2 *inStreamSizeCountSpec = new CSequentialInStreamSizeCount2;
|
||||
CMyComPtr<ISequentialInStream> inStreamSizeCount = inStreamSizeCountSpec;
|
||||
*/
|
||||
|
||||
CSequentialOutStreamSizeCount *outStreamSizeCountSpec = NULL;
|
||||
CMyComPtr<ISequentialOutStream> outStreamSizeCount;
|
||||
|
||||
inStreamSizeCountSpec->Init(inStream);
|
||||
// inStreamSizeCountSpec->Init(inStream);
|
||||
|
||||
// ISequentialInStream *inStreamPointer = inStreamSizeCount;
|
||||
ISequentialInStream *inStreamPointer = inStream;
|
||||
|
||||
ISequentialInStream *inStreamPointer = inStreamSizeCount;
|
||||
CRecordVector<ISequentialOutStream *> outStreamPointers;
|
||||
|
||||
SetFolder(folderItem);
|
||||
@@ -376,49 +387,66 @@ HRESULT CEncoder::Encode(
|
||||
for (i = 0; i < numMethods; i++)
|
||||
{
|
||||
IUnknown *coder = _mixer->GetCoder(i).GetUnknown();
|
||||
|
||||
CMyComPtr<ICryptoResetInitVector> resetInitVector;
|
||||
coder->QueryInterface(IID_ICryptoResetInitVector, (void **)&resetInitVector);
|
||||
if (resetInitVector)
|
||||
/*
|
||||
{
|
||||
resetInitVector->ResetInitVector();
|
||||
}
|
||||
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderPropertiesOpt> optProps;
|
||||
coder->QueryInterface(IID_ICompressSetCoderPropertiesOpt, (void **)&optProps);
|
||||
if (optProps)
|
||||
CEncoder *sfEncoder = NULL;
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
IGetSfEncoderInternal,
|
||||
sf, coder)
|
||||
if (sf)
|
||||
{
|
||||
PROPID propID = NCoderPropID::kExpectedDataSize;
|
||||
NWindows::NCOM::CPropVariant prop = (UInt64)unpackSize;
|
||||
RINOK(optProps->SetCoderPropertiesOpt(&propID, &prop, 1));
|
||||
RINOK(sf->GetSfEncoder(&sfEncoder));
|
||||
if (!sfEncoder)
|
||||
return E_FAIL;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
|
||||
coder->QueryInterface(IID_ICompressWriteCoderProperties, (void **)&writeCoderProperties);
|
||||
|
||||
CByteBuffer &props = folderItem.Coders[numMethods - 1 - i].Props;
|
||||
|
||||
if (writeCoderProperties)
|
||||
*/
|
||||
/*
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
{
|
||||
CDynBufSeqOutStream *outStreamSpec = new CDynBufSeqOutStream;
|
||||
CMyComPtr<ISequentialOutStream> dynOutStream(outStreamSpec);
|
||||
outStreamSpec->Init();
|
||||
RINOK(writeCoderProperties->WriteCoderProperties(dynOutStream));
|
||||
outStreamSpec->CopyToBuffer(props);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
ISetCompressCodecsInfo,
|
||||
setCompressCodecsInfo, coder)
|
||||
if (setCompressCodecsInfo)
|
||||
{
|
||||
// we must use g_ExternalCodecs also
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(_externalCodecs->GetCodecs))
|
||||
}
|
||||
}
|
||||
else
|
||||
props.Free();
|
||||
#endif
|
||||
*/
|
||||
{
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
ICryptoResetInitVector,
|
||||
resetInitVector, coder)
|
||||
if (resetInitVector)
|
||||
{
|
||||
RINOK(resetInitVector->ResetInitVector())
|
||||
}
|
||||
}
|
||||
{
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
ICompressSetCoderPropertiesOpt,
|
||||
optProps, coder)
|
||||
if (optProps)
|
||||
{
|
||||
const PROPID propID = NCoderPropID::kExpectedDataSize;
|
||||
NWindows::NCOM::CPropVariant prop = (UInt64)expectedDataSize;
|
||||
RINOK(optProps->SetCoderPropertiesOpt(&propID, &prop, 1))
|
||||
}
|
||||
}
|
||||
// we must write properties from coder after ResetInitVector()
|
||||
RINOK(FillProps_from_Coder(coder, folderItem.Coders[numMethods - 1 - i].Props))
|
||||
}
|
||||
|
||||
_mixer->SelectMainCoder(false);
|
||||
UInt32 mainCoder = _mixer->MainCoderIndex;
|
||||
const UInt32 mainCoder = _mixer->MainCoderIndex;
|
||||
|
||||
bool useMtProgress = false;
|
||||
if (!_mixer->Is_PackSize_Correct_for_Coder(mainCoder))
|
||||
{
|
||||
#ifdef _7ZIP_ST
|
||||
#ifdef Z7_ST
|
||||
if (!_mixer->IsThere_ExternalCoder_in_PackTree(mainCoder))
|
||||
#endif
|
||||
useMtProgress = true;
|
||||
@@ -433,11 +461,11 @@ HRESULT CEncoder::Encode(
|
||||
mtOutStreamNotifySpec = new CSequentialOutMtNotify;
|
||||
mtOutStreamNotify = mtOutStreamNotifySpec;
|
||||
mtOutStreamNotifySpec->_stream = outStream;
|
||||
mtOutStreamNotifySpec->_mtProgresSpec = mtProgressSpec;
|
||||
mtOutStreamNotifySpec->_mtProgressSpec = mtProgressSpec;
|
||||
|
||||
FOR_VECTOR(t, tempBufferSpecs)
|
||||
FOR_VECTOR (t, tempBufferSpecs)
|
||||
{
|
||||
tempBufferSpecs[t]->_mtProgresSpec = mtProgressSpec;
|
||||
tempBufferSpecs[t]->_mtProgressSpec = mtProgressSpec;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,35 +487,49 @@ HRESULT CEncoder::Encode(
|
||||
RINOK(_mixer->Code(
|
||||
&inStreamPointer,
|
||||
&outStreamPointers.Front(),
|
||||
mtProgress ? (ICompressProgressInfo *)mtProgress : compressProgress, dataAfterEnd_Error));
|
||||
mtProgress ? (ICompressProgressInfo *)mtProgress : compressProgress, dataAfterEnd_Error))
|
||||
|
||||
if (_bindInfo.PackStreams.Size() != 0)
|
||||
packSizes.Add(outStreamSizeCountSpec->GetSize());
|
||||
|
||||
for (i = 1; i < _bindInfo.PackStreams.Size(); i++)
|
||||
{
|
||||
CInOutTempBuffer &inOutTempBuffer = inOutTempBuffers[i - 1];
|
||||
RINOK(inOutTempBuffer.WriteToStream(outStream));
|
||||
packSizes.Add(inOutTempBuffer.GetDataSize());
|
||||
CInOutTempBuffer &iotb = tempBufferSpecs[i - 1]->TempBuffer;
|
||||
RINOK(iotb.WriteToStream(outStream))
|
||||
packSizes.Add(iotb.GetDataSize());
|
||||
}
|
||||
|
||||
unpackSize = 0;
|
||||
|
||||
for (i = 0; i < _bindInfo.Coders.Size(); i++)
|
||||
/* Code() in some future codec can change properties.
|
||||
v23: so we fill properties again after Code() */
|
||||
for (i = 0; i < numMethods; i++)
|
||||
{
|
||||
int bond = _bindInfo.FindBond_for_UnpackStream(_DestOut_to_SrcIn[i]);
|
||||
IUnknown *coder = _mixer->GetCoder(i).GetUnknown();
|
||||
RINOK(FillProps_from_Coder(coder, folderItem.Coders[numMethods - 1 - i].Props))
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
void CEncoder::Encode_Post(
|
||||
UInt64 unpackSize,
|
||||
CRecordVector<UInt64> &coderUnpackSizes)
|
||||
{
|
||||
// unpackSize = 0;
|
||||
for (unsigned i = 0; i < _bindInfo.Coders.Size(); i++)
|
||||
{
|
||||
const int bond = _bindInfo.FindBond_for_UnpackStream(DestOut_to_SrcIn[i]);
|
||||
UInt64 streamSize;
|
||||
if (bond < 0)
|
||||
{
|
||||
streamSize = inStreamSizeCountSpec->GetSize();
|
||||
unpackSize = streamSize;
|
||||
// streamSize = inStreamSizeCountSpec->GetSize();
|
||||
// unpackSize = streamSize;
|
||||
streamSize = unpackSize;
|
||||
}
|
||||
else
|
||||
streamSize = _mixer->GetBondStreamSize((unsigned)bond);
|
||||
coderUnpackSizes.Add(streamSize);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -610,15 +652,15 @@ HRESULT CEncoder::EncoderConstr()
|
||||
if (_bindInfo.Coders[ci].NumStreams == 0)
|
||||
break;
|
||||
|
||||
UInt32 outIndex = _bindInfo.Coder_to_Stream[ci];
|
||||
int bond = _bindInfo.FindBond_for_PackStream(outIndex);
|
||||
const UInt32 outIndex = _bindInfo.Coder_to_Stream[ci];
|
||||
const int bond = _bindInfo.FindBond_for_PackStream(outIndex);
|
||||
if (bond >= 0)
|
||||
{
|
||||
ci = _bindInfo.Bonds[(unsigned)bond].UnpackIndex;
|
||||
continue;
|
||||
}
|
||||
|
||||
int si = _bindInfo.FindStream_in_PackStreams(outIndex);
|
||||
const int si = _bindInfo.FindStream_in_PackStreams(outIndex);
|
||||
if (si >= 0)
|
||||
_bindInfo.PackStreams.MoveToFront((unsigned)si);
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 7zEncode.h
|
||||
|
||||
#ifndef __7Z_ENCODE_H
|
||||
#define __7Z_ENCODE_H
|
||||
#ifndef ZIP7_INC_7Z_ENCODE_H
|
||||
#define ZIP7_INC_7Z_ENCODE_H
|
||||
|
||||
#include "7zCompressionMode.h"
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
class CMtEncMultiProgress:
|
||||
public ICompressProgressInfo,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CMtEncMultiProgress,
|
||||
ICompressProgressInfo
|
||||
)
|
||||
CMyComPtr<ICompressProgressInfo> _progress;
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
NWindows::NSynchronization::CCriticalSection CriticalSection;
|
||||
#endif
|
||||
|
||||
@@ -30,18 +30,15 @@ public:
|
||||
|
||||
void AddOutSize(UInt64 addOutSize)
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
|
||||
#endif
|
||||
OutSize += addOutSize;
|
||||
}
|
||||
|
||||
MY_UNKNOWN_IMP1(ICompressProgressInfo)
|
||||
|
||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
||||
};
|
||||
|
||||
class CEncoder MY_UNCOPYABLE
|
||||
|
||||
class CEncoder Z7_final MY_UNCOPYABLE
|
||||
{
|
||||
#ifdef USE_MIXER_ST
|
||||
NCoderMixer2::CMixerST *_mixerST;
|
||||
@@ -57,10 +54,10 @@ class CEncoder MY_UNCOPYABLE
|
||||
NCoderMixer2::CBindInfo _bindInfo;
|
||||
CRecordVector<CMethodId> _decompressionMethods;
|
||||
|
||||
CRecordVector<UInt32> _SrcIn_to_DestOut;
|
||||
CRecordVector<UInt32> _SrcOut_to_DestIn;
|
||||
// CRecordVector<UInt32> _DestIn_to_SrcOut;
|
||||
CRecordVector<UInt32> _DestOut_to_SrcIn;
|
||||
CRecordVector<UInt32> SrcIn_to_DestOut;
|
||||
CRecordVector<UInt32> SrcOut_to_DestIn;
|
||||
// CRecordVector<UInt32> DestIn_to_SrcOut;
|
||||
CRecordVector<UInt32> DestOut_to_SrcIn;
|
||||
|
||||
void InitBindConv();
|
||||
void SetFolder(CFolder &folder);
|
||||
@@ -74,17 +71,23 @@ public:
|
||||
CEncoder(const CCompressionMethodMode &options);
|
||||
~CEncoder();
|
||||
HRESULT EncoderConstr();
|
||||
HRESULT Encode(
|
||||
HRESULT Encode1(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
ISequentialInStream *inStream,
|
||||
// const UInt64 *inStreamSize,
|
||||
const UInt64 *inSizeForReduce,
|
||||
UInt64 expectedDataSize,
|
||||
CFolder &folderItem,
|
||||
CRecordVector<UInt64> &coderUnpackSizes,
|
||||
UInt64 &unpackSize,
|
||||
// CRecordVector<UInt64> &coderUnpackSizes,
|
||||
// UInt64 &unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
CRecordVector<UInt64> &packSizes,
|
||||
ICompressProgressInfo *compressProgress);
|
||||
|
||||
void Encode_Post(
|
||||
UInt64 unpackSize,
|
||||
CRecordVector<UInt64> &coderUnpackSizes);
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
class CFolderOutStream:
|
||||
public ISequentialOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CFolderOutStream
|
||||
, ISequentialOutStream
|
||||
/* , ICompressGetSubStreamSize */
|
||||
)
|
||||
CMyComPtr<ISequentialOutStream> _stream;
|
||||
public:
|
||||
bool TestMode;
|
||||
@@ -31,6 +32,7 @@ private:
|
||||
UInt64 _rem;
|
||||
|
||||
const UInt32 *_indexes;
|
||||
// unsigned _startIndex;
|
||||
unsigned _numFiles;
|
||||
unsigned _fileIndex;
|
||||
|
||||
@@ -40,8 +42,6 @@ private:
|
||||
HRESULT ProcessEmptyFiles();
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(ISequentialOutStream)
|
||||
|
||||
const CDbEx *_db;
|
||||
CMyComPtr<IArchiveExtractCallback> ExtractCallback;
|
||||
|
||||
@@ -52,8 +52,6 @@ public:
|
||||
CheckCrc(true)
|
||||
{}
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
|
||||
HRESULT Init(unsigned startIndex, const UInt32 *indexes, unsigned numFiles);
|
||||
HRESULT FlushCorrupted(Int32 callbackOperationResult);
|
||||
|
||||
@@ -63,6 +61,7 @@ public:
|
||||
|
||||
HRESULT CFolderOutStream::Init(unsigned startIndex, const UInt32 *indexes, unsigned numFiles)
|
||||
{
|
||||
// _startIndex = startIndex;
|
||||
_fileIndex = startIndex;
|
||||
_indexes = indexes;
|
||||
_numFiles = numFiles;
|
||||
@@ -76,11 +75,10 @@ HRESULT CFolderOutStream::Init(unsigned startIndex, const UInt32 *indexes, unsig
|
||||
HRESULT CFolderOutStream::OpenFile(bool isCorrupted)
|
||||
{
|
||||
const CFileItem &fi = _db->Files[_fileIndex];
|
||||
UInt32 nextFileIndex = (_indexes ? *_indexes : _fileIndex);
|
||||
Int32 askMode = (_fileIndex == nextFileIndex) ?
|
||||
(TestMode ?
|
||||
NExtract::NAskMode::kTest :
|
||||
NExtract::NAskMode::kExtract) :
|
||||
const UInt32 nextFileIndex = (_indexes ? *_indexes : _fileIndex);
|
||||
Int32 askMode = (_fileIndex == nextFileIndex) ? TestMode ?
|
||||
NExtract::NAskMode::kTest :
|
||||
NExtract::NAskMode::kExtract :
|
||||
NExtract::NAskMode::kSkip;
|
||||
|
||||
if (isCorrupted
|
||||
@@ -90,7 +88,7 @@ HRESULT CFolderOutStream::OpenFile(bool isCorrupted)
|
||||
askMode = NExtract::NAskMode::kTest;
|
||||
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
RINOK(ExtractCallback->GetStream(_fileIndex, &realOutStream, askMode));
|
||||
RINOK(ExtractCallback->GetStream(_fileIndex, &realOutStream, askMode))
|
||||
|
||||
_stream = realOutStream;
|
||||
_crc = CRC_INIT_VAL;
|
||||
@@ -136,13 +134,13 @@ HRESULT CFolderOutStream::ProcessEmptyFiles()
|
||||
{
|
||||
while (_numFiles != 0 && _db->Files[_fileIndex].Size == 0)
|
||||
{
|
||||
RINOK(OpenFile());
|
||||
RINOK(CloseFile());
|
||||
RINOK(OpenFile())
|
||||
RINOK(CloseFile())
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
if (processedSize)
|
||||
*processedSize = 0;
|
||||
@@ -170,16 +168,16 @@ STDMETHODIMP CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *proc
|
||||
_rem -= cur;
|
||||
if (_rem == 0)
|
||||
{
|
||||
RINOK(CloseFile());
|
||||
RINOK(ProcessEmptyFiles());
|
||||
RINOK(CloseFile())
|
||||
RINOK(ProcessEmptyFiles())
|
||||
}
|
||||
RINOK(result);
|
||||
RINOK(result)
|
||||
if (cur == 0)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
RINOK(ProcessEmptyFiles());
|
||||
RINOK(ProcessEmptyFiles())
|
||||
if (_numFiles == 0)
|
||||
{
|
||||
// we support partial extracting
|
||||
@@ -192,7 +190,7 @@ STDMETHODIMP CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *proc
|
||||
// return S_FALSE;
|
||||
return k_My_HRESULT_WritingWasCut;
|
||||
}
|
||||
RINOK(OpenFile());
|
||||
RINOK(OpenFile())
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
@@ -204,18 +202,32 @@ HRESULT CFolderOutStream::FlushCorrupted(Int32 callbackOperationResult)
|
||||
{
|
||||
if (_fileIsOpen)
|
||||
{
|
||||
RINOK(CloseFile_and_SetResult(callbackOperationResult));
|
||||
RINOK(CloseFile_and_SetResult(callbackOperationResult))
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(OpenFile(true));
|
||||
RINOK(OpenFile(true))
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
Int32 testModeSpec, IArchiveExtractCallback *extractCallbackSpec)
|
||||
/*
|
||||
Z7_COM7F_IMF(CFolderOutStream::GetSubStreamSize(UInt64 subStream, UInt64 *value))
|
||||
{
|
||||
*value = 0;
|
||||
// const unsigned numFiles_Original = _numFiles + _fileIndex - _startIndex;
|
||||
const unsigned numFiles_Original = _numFiles;
|
||||
if (subStream >= numFiles_Original)
|
||||
return S_FALSE; // E_FAIL;
|
||||
*value = _db->Files[_startIndex + (unsigned)subStream].Size;
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
Int32 testModeSpec, IArchiveExtractCallback *extractCallbackSpec))
|
||||
{
|
||||
// for GCC
|
||||
// CFolderOutStream *folderOutStream = new CFolderOutStream;
|
||||
@@ -229,7 +241,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
// numItems = (UInt32)(Int32)-1;
|
||||
|
||||
bool allFilesMode = (numItems == (UInt32)(Int32)-1);
|
||||
const bool allFilesMode = (numItems == (UInt32)(Int32)-1);
|
||||
if (allFilesMode)
|
||||
numItems = _db.Files.Size();
|
||||
|
||||
@@ -244,8 +256,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
UInt32 fileIndex = allFilesMode ? i : indices[i];
|
||||
CNum folderIndex = _db.FileIndexToFolderIndexMap[fileIndex];
|
||||
const UInt32 fileIndex = allFilesMode ? i : indices[i];
|
||||
const CNum folderIndex = _db.FileIndexToFolderIndexMap[fileIndex];
|
||||
if (folderIndex == kNumNoIndex)
|
||||
continue;
|
||||
if (folderIndex != prevFolder || fileIndex < nextFile)
|
||||
@@ -257,7 +269,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
}
|
||||
}
|
||||
|
||||
RINOK(extractCallback->SetTotal(importantTotalUnpacked));
|
||||
RINOK(extractCallback->SetTotal(importantTotalUnpacked))
|
||||
|
||||
CLocalProgress *lps = new CLocalProgress;
|
||||
CMyComPtr<ICompressProgressInfo> progress = lps;
|
||||
@@ -268,8 +280,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
false
|
||||
#elif !defined(USE_MIXER_ST)
|
||||
true
|
||||
#elif !defined(__7Z_SET_PROPERTIES)
|
||||
#ifdef _7ZIP_ST
|
||||
#elif !defined(Z7_7Z_SET_PROPERTIES)
|
||||
#ifdef Z7_ST
|
||||
false
|
||||
#else
|
||||
true
|
||||
@@ -281,8 +293,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
UInt64 curPacked, curUnpacked;
|
||||
|
||||
CMyComPtr<IArchiveExtractCallbackMessage> callbackMessage;
|
||||
extractCallback.QueryInterface(IID_IArchiveExtractCallbackMessage, &callbackMessage);
|
||||
CMyComPtr<IArchiveExtractCallbackMessage2> callbackMessage;
|
||||
extractCallback.QueryInterface(IID_IArchiveExtractCallbackMessage2, &callbackMessage);
|
||||
|
||||
CFolderOutStream *folderOutStream = new CFolderOutStream;
|
||||
CMyComPtr<ISequentialOutStream> outStream(folderOutStream);
|
||||
@@ -294,7 +306,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
for (UInt32 i = 0;; lps->OutSize += curUnpacked, lps->InSize += curPacked)
|
||||
{
|
||||
RINOK(lps->SetCur());
|
||||
RINOK(lps->SetCur())
|
||||
|
||||
if (i >= numItems)
|
||||
break;
|
||||
@@ -303,7 +315,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
curPacked = 0;
|
||||
|
||||
UInt32 fileIndex = allFilesMode ? i : indices[i];
|
||||
CNum folderIndex = _db.FileIndexToFolderIndexMap[fileIndex];
|
||||
const CNum folderIndex = _db.FileIndexToFolderIndexMap[fileIndex];
|
||||
|
||||
UInt32 numSolidFiles = 1;
|
||||
|
||||
@@ -316,7 +328,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
for (k = i + 1; k < numItems; k++)
|
||||
{
|
||||
UInt32 fileIndex2 = allFilesMode ? k : indices[k];
|
||||
const UInt32 fileIndex2 = allFilesMode ? k : indices[k];
|
||||
if (_db.FileIndexToFolderIndexMap[fileIndex2] != folderIndex
|
||||
|| fileIndex2 < nextFile)
|
||||
break;
|
||||
@@ -330,20 +342,26 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
}
|
||||
|
||||
{
|
||||
HRESULT result = folderOutStream->Init(fileIndex,
|
||||
const HRESULT result = folderOutStream->Init(fileIndex,
|
||||
allFilesMode ? NULL : indices + i,
|
||||
numSolidFiles);
|
||||
|
||||
i += numSolidFiles;
|
||||
|
||||
RINOK(result);
|
||||
RINOK(result)
|
||||
}
|
||||
|
||||
// to test solid block with zero unpacked size we disable that code
|
||||
if (folderOutStream->WasWritingFinished())
|
||||
{
|
||||
// for debug: to test zero size stream unpacking
|
||||
// if (folderIndex == kNumNoIndex) // enable this check for debug
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
if (folderIndex == kNumNoIndex)
|
||||
return E_FAIL;
|
||||
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
CMyComPtr<ICryptoGetTextPassword> getTextPassword;
|
||||
if (extractCallback)
|
||||
extractCallback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
|
||||
@@ -351,16 +369,15 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
try
|
||||
{
|
||||
#ifndef _NO_CRYPTO
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
bool isEncrypted = false;
|
||||
bool passwordIsDefined = false;
|
||||
UString_Wipe password;
|
||||
#endif
|
||||
|
||||
|
||||
bool dataAfterEnd_Error = false;
|
||||
|
||||
HRESULT result = decoder.Decode(
|
||||
const HRESULT result = decoder.Decode(
|
||||
EXTERNAL_CODECS_VARS
|
||||
_inStream,
|
||||
_db.ArcInfo.DataStartPosition,
|
||||
@@ -372,15 +389,15 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
NULL // *inStreamMainRes
|
||||
, dataAfterEnd_Error
|
||||
|
||||
_7Z_DECODER_CRYPRO_VARS
|
||||
#if !defined(_7ZIP_ST)
|
||||
Z7_7Z_DECODER_CRYPRO_VARS
|
||||
#if !defined(Z7_ST)
|
||||
, true, _numThreads, _memUsage_Decompress
|
||||
#endif
|
||||
);
|
||||
|
||||
if (result == S_FALSE || result == E_NOTIMPL || dataAfterEnd_Error)
|
||||
{
|
||||
bool wasFinished = folderOutStream->WasWritingFinished();
|
||||
const bool wasFinished = folderOutStream->WasWritingFinished();
|
||||
|
||||
int resOp = NExtract::NOperationResult::kDataError;
|
||||
|
||||
@@ -392,14 +409,14 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
resOp = NExtract::NOperationResult::kDataAfterEnd;
|
||||
}
|
||||
|
||||
RINOK(folderOutStream->FlushCorrupted(resOp));
|
||||
RINOK(folderOutStream->FlushCorrupted(resOp))
|
||||
|
||||
if (wasFinished)
|
||||
{
|
||||
// we don't show error, if it's after required files
|
||||
if (/* !folderOutStream->ExtraWriteWasCut && */ callbackMessage)
|
||||
{
|
||||
RINOK(callbackMessage->ReportExtractResult(NEventIndexType::kBlockIndex, folderIndex, resOp));
|
||||
RINOK(callbackMessage->ReportExtractResult(NEventIndexType::kBlockIndex, folderIndex, resOp))
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@@ -408,12 +425,12 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
if (result != S_OK)
|
||||
return result;
|
||||
|
||||
RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kDataError));
|
||||
RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kDataError))
|
||||
continue;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kDataError));
|
||||
RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kDataError))
|
||||
// continue;
|
||||
// return E_FAIL;
|
||||
throw;
|
||||
|
||||
@@ -15,32 +15,38 @@ void CFolderInStream::Init(IArchiveUpdateCallback *updateCallback,
|
||||
_updateCallback = updateCallback;
|
||||
_indexes = indexes;
|
||||
_numFiles = numFiles;
|
||||
|
||||
_totalSize_for_Coder = 0;
|
||||
ClearFileInfo();
|
||||
|
||||
Processed.ClearAndReserve(numFiles);
|
||||
CRCs.ClearAndReserve(numFiles);
|
||||
Sizes.ClearAndReserve(numFiles);
|
||||
|
||||
if (Need_CTime) CTimes.ClearAndReserve(numFiles);
|
||||
if (Need_ATime) ATimes.ClearAndReserve(numFiles);
|
||||
if (Need_MTime) MTimes.ClearAndReserve(numFiles);
|
||||
if (Need_Attrib) Attribs.ClearAndReserve(numFiles);
|
||||
CRCs.ClearAndReserve(numFiles);
|
||||
TimesDefined.ClearAndReserve(numFiles);
|
||||
|
||||
MTimes.ClearAndReserve(Need_MTime ? numFiles : (unsigned)0);
|
||||
CTimes.ClearAndReserve(Need_CTime ? numFiles : (unsigned)0);
|
||||
ATimes.ClearAndReserve(Need_ATime ? numFiles : (unsigned)0);
|
||||
Attribs.ClearAndReserve(Need_Attrib ? numFiles : (unsigned)0);
|
||||
|
||||
// FolderCrc = CRC_INIT_VAL;
|
||||
_stream.Release();
|
||||
}
|
||||
|
||||
HRESULT CFolderInStream::OpenStream()
|
||||
void CFolderInStream::ClearFileInfo()
|
||||
{
|
||||
_pos = 0;
|
||||
_crc = CRC_INIT_VAL;
|
||||
_size_Defined = false;
|
||||
_times_Defined = false;
|
||||
_size = 0;
|
||||
FILETIME_Clear(_mTime);
|
||||
FILETIME_Clear(_cTime);
|
||||
FILETIME_Clear(_aTime);
|
||||
FILETIME_Clear(_mTime);
|
||||
_attrib = 0;
|
||||
}
|
||||
|
||||
HRESULT CFolderInStream::OpenStream()
|
||||
{
|
||||
while (Processed.Size() < _numFiles)
|
||||
{
|
||||
CMyComPtr<ISequentialInStream> stream;
|
||||
@@ -83,7 +89,7 @@ HRESULT CFolderInStream::OpenStream()
|
||||
}
|
||||
}
|
||||
|
||||
RINOK(AddFileInfo(result == S_OK));
|
||||
RINOK(AddFileInfo(result == S_OK))
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -117,13 +123,13 @@ HRESULT CFolderInStream::AddFileInfo(bool isProcessed)
|
||||
// const UInt32 index = _indexes[Processed.Size()];
|
||||
Processed.AddInReserved(isProcessed);
|
||||
Sizes.AddInReserved(_pos);
|
||||
const UInt32 crc = CRC_GET_DIGEST(_crc);
|
||||
CRCs.AddInReserved(crc);
|
||||
CRCs.AddInReserved(CRC_GET_DIGEST(_crc));
|
||||
if (Need_Attrib) Attribs.AddInReserved(_attrib);
|
||||
TimesDefined.AddInReserved(_times_Defined);
|
||||
if (Need_MTime) AddFt(MTimes, _mTime);
|
||||
if (Need_CTime) AddFt(CTimes, _cTime);
|
||||
if (Need_ATime) AddFt(ATimes, _aTime);
|
||||
if (Need_MTime) AddFt(MTimes, _mTime);
|
||||
if (Need_Attrib) Attribs.AddInReserved(_attrib);
|
||||
ClearFileInfo();
|
||||
/*
|
||||
if (isProcessed && _reportArcProp)
|
||||
RINOK(ReportItemProps(_reportArcProp, index, _pos, &crc))
|
||||
@@ -131,7 +137,7 @@ HRESULT CFolderInStream::AddFileInfo(bool isProcessed)
|
||||
return _updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK);
|
||||
}
|
||||
|
||||
STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
if (processedSize)
|
||||
*processedSize = 0;
|
||||
@@ -139,38 +145,65 @@ STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSiz
|
||||
{
|
||||
if (_stream)
|
||||
{
|
||||
/*
|
||||
if (_pos == 0)
|
||||
{
|
||||
const UInt32 align = (UInt32)1 << AlignLog;
|
||||
const UInt32 offset = (UInt32)_totalSize_for_Coder & (align - 1);
|
||||
if (offset != 0)
|
||||
{
|
||||
UInt32 cur = align - offset;
|
||||
if (cur > size)
|
||||
cur = size;
|
||||
memset(data, 0, cur);
|
||||
data = (Byte *)data + cur;
|
||||
size -= cur;
|
||||
// _pos += cur; // for debug
|
||||
_totalSize_for_Coder += cur;
|
||||
if (processedSize)
|
||||
*processedSize += cur;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
*/
|
||||
UInt32 cur = size;
|
||||
const UInt32 kMax = (UInt32)1 << 20;
|
||||
if (cur > kMax)
|
||||
cur = kMax;
|
||||
RINOK(_stream->Read(data, cur, &cur));
|
||||
RINOK(_stream->Read(data, cur, &cur))
|
||||
if (cur != 0)
|
||||
{
|
||||
// if (Need_Crc)
|
||||
_crc = CrcUpdate(_crc, data, cur);
|
||||
/*
|
||||
if (FolderCrc)
|
||||
FolderCrc = CrcUpdate(FolderCrc, data, cur);
|
||||
*/
|
||||
_pos += cur;
|
||||
_totalSize_for_Coder += cur;
|
||||
if (processedSize)
|
||||
*processedSize = cur;
|
||||
*processedSize = cur; // use +=cur, if continue is possible in loop
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
_stream.Release();
|
||||
RINOK(AddFileInfo(true));
|
||||
RINOK(AddFileInfo(true))
|
||||
}
|
||||
|
||||
if (Processed.Size() >= _numFiles)
|
||||
break;
|
||||
RINOK(OpenStream());
|
||||
RINOK(OpenStream())
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFolderInStream::GetSubStreamSize(UInt64 subStream, UInt64 *value)
|
||||
Z7_COM7F_IMF(CFolderInStream::GetSubStreamSize(UInt64 subStream, UInt64 *value))
|
||||
{
|
||||
*value = 0;
|
||||
if (subStream > Sizes.Size())
|
||||
return S_FALSE; // E_FAIL;
|
||||
|
||||
unsigned index = (unsigned)subStream;
|
||||
const unsigned index = (unsigned)subStream;
|
||||
if (index < Sizes.Size())
|
||||
{
|
||||
*value = Sizes[index];
|
||||
@@ -187,4 +220,45 @@ STDMETHODIMP CFolderInStream::GetSubStreamSize(UInt64 subStream, UInt64 *value)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
HRESULT CFolderInStream::CloseCrcStream()
|
||||
{
|
||||
if (!_crcStream)
|
||||
return S_OK;
|
||||
if (!_crcStream_Spec->WasFinished())
|
||||
return E_FAIL;
|
||||
_crc = _crcStream_Spec->GetCRC() ^ CRC_INIT_VAL; // change it
|
||||
const UInt64 size = _crcStream_Spec->GetSize();
|
||||
_pos = size;
|
||||
_totalSize_for_Coder += size;
|
||||
_crcStream.Release();
|
||||
// _crcStream->ReleaseStream();
|
||||
_stream.Release();
|
||||
return AddFileInfo(true);
|
||||
}
|
||||
|
||||
Z7_COM7F_IMF(CFolderInStream::GetNextInSubStream(UInt64 *streamIndexRes, ISequentialInStream **stream)
|
||||
{
|
||||
RINOK(CloseCrcStream())
|
||||
*stream = NULL;
|
||||
*streamIndexRes = Processed.Size();
|
||||
if (Processed.Size() >= _numFiles)
|
||||
return S_OK;
|
||||
RINOK(OpenStream());
|
||||
if (!_stream)
|
||||
return S_OK;
|
||||
if (!_crcStream)
|
||||
{
|
||||
_crcStream_Spec = new CSequentialInStreamWithCRC;
|
||||
_crcStream = _crcStream_Spec;
|
||||
}
|
||||
_crcStream_Spec->Init();
|
||||
_crcStream_Spec->SetStream(_stream);
|
||||
*stream = _crcStream;
|
||||
_crcStream->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
}}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// 7zFolderInStream.h
|
||||
|
||||
#ifndef __7Z_FOLDER_IN_STREAM_H
|
||||
#define __7Z_FOLDER_IN_STREAM_H
|
||||
#ifndef ZIP7_INC_7Z_FOLDER_IN_STREAM_H
|
||||
#define ZIP7_INC_7Z_FOLDER_IN_STREAM_H
|
||||
|
||||
#include "../../../../C/7zCrc.h"
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../../Common/MyVector.h"
|
||||
// #include "../Common/InStreamWithCRC.h"
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../IArchive.h"
|
||||
@@ -14,20 +15,26 @@
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
class CFolderInStream:
|
||||
public ISequentialInStream,
|
||||
public ICompressGetSubStreamSize,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_2(
|
||||
CFolderInStream
|
||||
, ISequentialInStream
|
||||
, ICompressGetSubStreamSize
|
||||
)
|
||||
/*
|
||||
Z7_COM7F_IMP(GetNextStream(UInt64 *streamIndex))
|
||||
Z7_IFACE_COM7_IMP(ICompressInSubStreams)
|
||||
*/
|
||||
|
||||
CMyComPtr<ISequentialInStream> _stream;
|
||||
UInt64 _totalSize_for_Coder;
|
||||
UInt64 _pos;
|
||||
UInt32 _crc;
|
||||
bool _size_Defined;
|
||||
bool _times_Defined;
|
||||
UInt64 _size;
|
||||
FILETIME _mTime;
|
||||
FILETIME _cTime;
|
||||
FILETIME _aTime;
|
||||
FILETIME _mTime;
|
||||
UInt32 _attrib;
|
||||
|
||||
unsigned _numFiles;
|
||||
@@ -35,34 +42,40 @@ class CFolderInStream:
|
||||
|
||||
CMyComPtr<IArchiveUpdateCallback> _updateCallback;
|
||||
|
||||
void ClearFileInfo();
|
||||
HRESULT OpenStream();
|
||||
HRESULT AddFileInfo(bool isProcessed);
|
||||
|
||||
// HRESULT CloseCrcStream();
|
||||
public:
|
||||
CRecordVector<bool> Processed;
|
||||
CRecordVector<UInt32> CRCs;
|
||||
CRecordVector<UInt64> Sizes;
|
||||
CRecordVector<UInt64> CTimes;
|
||||
CRecordVector<UInt64> ATimes;
|
||||
CRecordVector<UInt64> MTimes;
|
||||
CRecordVector<UInt32> Attribs;
|
||||
CRecordVector<bool> TimesDefined;
|
||||
|
||||
bool Need_MTime;
|
||||
bool Need_CTime;
|
||||
bool Need_ATime;
|
||||
bool Need_MTime;
|
||||
bool Need_Attrib;
|
||||
// bool Need_Crc;
|
||||
// bool Need_FolderCrc;
|
||||
// unsigned AlignLog;
|
||||
|
||||
CRecordVector<bool> Processed;
|
||||
CRecordVector<UInt64> Sizes;
|
||||
CRecordVector<UInt32> CRCs;
|
||||
CRecordVector<UInt32> Attribs;
|
||||
CRecordVector<bool> TimesDefined;
|
||||
CRecordVector<UInt64> MTimes;
|
||||
CRecordVector<UInt64> CTimes;
|
||||
CRecordVector<UInt64> ATimes;
|
||||
// UInt32 FolderCrc;
|
||||
|
||||
// UInt32 GetFolderCrc() const { return CRC_GET_DIGEST(FolderCrc); }
|
||||
// CSequentialInStreamWithCRC *_crcStream_Spec;
|
||||
// CMyComPtr<ISequentialInStream> _crcStream;
|
||||
// CMyComPtr<IArchiveUpdateCallbackArcProp> _reportArcProp;
|
||||
|
||||
MY_UNKNOWN_IMP2(ISequentialInStream, ICompressGetSubStreamSize)
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value);
|
||||
|
||||
void Init(IArchiveUpdateCallback *updateCallback, const UInt32 *indexes, unsigned numFiles);
|
||||
|
||||
bool WasFinished() const { return Processed.Size() == _numFiles; }
|
||||
|
||||
UInt64 Get_TotalSize_for_Coder() const { return _totalSize_for_Coder; }
|
||||
/*
|
||||
UInt64 GetFullSize() const
|
||||
{
|
||||
UInt64 size = 0;
|
||||
@@ -70,12 +83,16 @@ public:
|
||||
size += Sizes[i];
|
||||
return size;
|
||||
}
|
||||
*/
|
||||
|
||||
CFolderInStream():
|
||||
Need_MTime(false),
|
||||
Need_CTime(false),
|
||||
Need_ATime(false),
|
||||
Need_MTime(false),
|
||||
Need_Attrib(false)
|
||||
// , Need_Crc(true)
|
||||
// , Need_FolderCrc(false)
|
||||
// , AlignLog(0)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "../../../Common/ComTry.h"
|
||||
#include "../../../Common/IntToString.h"
|
||||
|
||||
#ifndef __7Z_SET_PROPERTIES
|
||||
#ifndef Z7_7Z_SET_PROPERTIES
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#include "7zHandler.h"
|
||||
#include "7zProperties.h"
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
#ifdef EXTRACT_ONLY
|
||||
#ifdef Z7_7Z_SET_PROPERTIES
|
||||
#ifdef Z7_EXTRACT_ONLY
|
||||
#include "../Common/ParseProperties.h"
|
||||
#endif
|
||||
#endif
|
||||
@@ -30,40 +30,40 @@ namespace N7z {
|
||||
|
||||
CHandler::CHandler()
|
||||
{
|
||||
#ifndef _NO_CRYPTO
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
_isEncrypted = false;
|
||||
_passwordIsDefined = false;
|
||||
#endif
|
||||
|
||||
#ifdef EXTRACT_ONLY
|
||||
#ifdef Z7_EXTRACT_ONLY
|
||||
|
||||
_crcSize = 4;
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
#ifdef Z7_7Z_SET_PROPERTIES
|
||||
_useMultiThreadMixer = true;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
Z7_COM7F_IMF(CHandler::GetNumberOfItems(UInt32 *numItems))
|
||||
{
|
||||
*numItems = _db.Files.Size();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef _SFX
|
||||
#ifdef Z7_SFX
|
||||
|
||||
IMP_IInArchive_ArcProps_NO_Table
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProps)
|
||||
Z7_COM7F_IMF(CHandler::GetNumberOfProperties(UInt32 *numProps))
|
||||
{
|
||||
*numProps = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetPropertyInfo(UInt32 /* index */,
|
||||
BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */)
|
||||
Z7_COM7F_IMF(CHandler::GetPropertyInfo(UInt32 /* index */,
|
||||
BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */))
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@@ -110,8 +110,7 @@ static void ConvertMethodIdToString(AString &res, UInt64 id)
|
||||
|
||||
static char *GetStringForSizeValue(char *s, UInt32 val)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i <= 31; i++)
|
||||
for (unsigned i = 0; i < 32; i++)
|
||||
if (((UInt32)1 << i) == val)
|
||||
{
|
||||
if (i >= 10)
|
||||
@@ -190,15 +189,15 @@ void CHandler::AddMethodName(AString &s, UInt64 id)
|
||||
|
||||
#endif
|
||||
|
||||
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
Z7_COM7F_IMF(CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value))
|
||||
{
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
COM_TRY_BEGIN
|
||||
#endif
|
||||
NCOM::CPropVariant prop;
|
||||
switch (propID)
|
||||
{
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
case kpidMethod:
|
||||
{
|
||||
AString s;
|
||||
@@ -220,6 +219,12 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
GetStringForSizeValue(temp, pm.LzmaDic);
|
||||
s += temp;
|
||||
}
|
||||
/*
|
||||
else if (id == k_ZSTD)
|
||||
{
|
||||
s += "ZSTD";
|
||||
}
|
||||
*/
|
||||
else
|
||||
AddMethodName(s, id);
|
||||
}
|
||||
@@ -269,7 +274,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
}
|
||||
}
|
||||
return prop.Detach(value);
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
COM_TRY_END
|
||||
#endif
|
||||
}
|
||||
@@ -285,17 +290,17 @@ bool CHandler::IsFolderEncrypted(CNum folderIndex) const
|
||||
{
|
||||
if (folderIndex == kNumNoIndex)
|
||||
return false;
|
||||
size_t startPos = _db.FoCodersDataOffset[folderIndex];
|
||||
const size_t startPos = _db.FoCodersDataOffset[folderIndex];
|
||||
const Byte *p = _db.CodersData + startPos;
|
||||
size_t size = _db.FoCodersDataOffset[folderIndex + 1] - startPos;
|
||||
const size_t size = _db.FoCodersDataOffset[folderIndex + 1] - startPos;
|
||||
CInByte2 inByte;
|
||||
inByte.Init(p, size);
|
||||
|
||||
CNum numCoders = inByte.ReadNum();
|
||||
for (; numCoders != 0; numCoders--)
|
||||
{
|
||||
Byte mainByte = inByte.ReadByte();
|
||||
unsigned idSize = (mainByte & 0xF);
|
||||
const Byte mainByte = inByte.ReadByte();
|
||||
const unsigned idSize = (mainByte & 0xF);
|
||||
const Byte *longID = inByte.GetPtr();
|
||||
UInt64 id64 = 0;
|
||||
for (unsigned j = 0; j < idSize; j++)
|
||||
@@ -309,20 +314,20 @@ bool CHandler::IsFolderEncrypted(CNum folderIndex) const
|
||||
return false;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumRawProps(UInt32 *numProps)
|
||||
Z7_COM7F_IMF(CHandler::GetNumRawProps(UInt32 *numProps))
|
||||
{
|
||||
*numProps = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID)
|
||||
Z7_COM7F_IMF(CHandler::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID))
|
||||
{
|
||||
*name = NULL;
|
||||
*propID = kpidNtSecure;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetParent(UInt32 /* index */, UInt32 *parent, UInt32 *parentType)
|
||||
Z7_COM7F_IMF(CHandler::GetParent(UInt32 /* index */, UInt32 *parent, UInt32 *parentType))
|
||||
{
|
||||
/*
|
||||
const CFileItem &file = _db.Files[index];
|
||||
@@ -334,7 +339,7 @@ STDMETHODIMP CHandler::GetParent(UInt32 /* index */, UInt32 *parent, UInt32 *par
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType)
|
||||
Z7_COM7F_IMF(CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType))
|
||||
{
|
||||
*data = NULL;
|
||||
*dataSize = 0;
|
||||
@@ -376,7 +381,7 @@ STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
|
||||
HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
|
||||
{
|
||||
@@ -389,9 +394,9 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
|
||||
unsigned pos = kTempSize;
|
||||
temp[--pos] = 0;
|
||||
|
||||
size_t startPos = _db.FoCodersDataOffset[folderIndex];
|
||||
const size_t startPos = _db.FoCodersDataOffset[folderIndex];
|
||||
const Byte *p = _db.CodersData + startPos;
|
||||
size_t size = _db.FoCodersDataOffset[folderIndex + 1] - startPos;
|
||||
const size_t size = _db.FoCodersDataOffset[folderIndex + 1] - startPos;
|
||||
CInByte2 inByte;
|
||||
inByte.Init(p, size);
|
||||
|
||||
@@ -403,10 +408,10 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
|
||||
{
|
||||
if (pos < 32) // max size of property
|
||||
break;
|
||||
Byte mainByte = inByte.ReadByte();
|
||||
unsigned idSize = (mainByte & 0xF);
|
||||
const Byte *longID = inByte.GetPtr();
|
||||
const Byte mainByte = inByte.ReadByte();
|
||||
UInt64 id64 = 0;
|
||||
const unsigned idSize = (mainByte & 0xF);
|
||||
const Byte *longID = inByte.GetPtr();
|
||||
for (unsigned j = 0; j < idSize; j++)
|
||||
id64 = ((id64 << 8) | longID[j]);
|
||||
inByte.SkipDataNoCheck(idSize);
|
||||
@@ -432,21 +437,21 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
|
||||
|
||||
if (id64 <= (UInt32)0xFFFFFFFF)
|
||||
{
|
||||
UInt32 id = (UInt32)id64;
|
||||
const UInt32 id = (UInt32)id64;
|
||||
if (id == k_LZMA)
|
||||
{
|
||||
name = "LZMA";
|
||||
if (propsSize == 5)
|
||||
{
|
||||
UInt32 dicSize = GetUi32((const Byte *)props + 1);
|
||||
const UInt32 dicSize = GetUi32((const Byte *)props + 1);
|
||||
char *dest = GetStringForSizeValue(s, dicSize);
|
||||
UInt32 d = props[0];
|
||||
if (d != 0x5D)
|
||||
{
|
||||
UInt32 lc = d % 9;
|
||||
const UInt32 lc = d % 9;
|
||||
d /= 9;
|
||||
UInt32 pb = d / 5;
|
||||
UInt32 lp = d % 5;
|
||||
const UInt32 pb = d / 5;
|
||||
const UInt32 lp = d % 5;
|
||||
if (lc != 3) dest = AddProp32(dest, "lc", lc);
|
||||
if (lp != 0) dest = AddProp32(dest, "lp", lp);
|
||||
if (pb != 2) dest = AddProp32(dest, "pb", pb);
|
||||
@@ -477,6 +482,16 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
|
||||
if (propsSize == 1)
|
||||
ConvertUInt32ToString((UInt32)props[0] + 1, s);
|
||||
}
|
||||
else if (id == k_ARM64)
|
||||
{
|
||||
name = "ARM64";
|
||||
if (propsSize == 4)
|
||||
ConvertUInt32ToString(GetUi32(props), s);
|
||||
/*
|
||||
else if (propsSize != 0)
|
||||
MyStringCopy(s, "unsupported");
|
||||
*/
|
||||
}
|
||||
else if (id == k_BCJ2) name = "BCJ2";
|
||||
else if (id == k_BCJ) name = "BCJ";
|
||||
else if (id == k_AES)
|
||||
@@ -484,8 +499,8 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
|
||||
name = "7zAES";
|
||||
if (propsSize >= 1)
|
||||
{
|
||||
Byte firstByte = props[0];
|
||||
UInt32 numCyclesPower = firstByte & 0x3F;
|
||||
const Byte firstByte = props[0];
|
||||
const UInt32 numCyclesPower = firstByte & 0x3F;
|
||||
ConvertUInt32ToString(numCyclesPower, s);
|
||||
}
|
||||
}
|
||||
@@ -493,8 +508,8 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
|
||||
|
||||
if (name)
|
||||
{
|
||||
unsigned nameLen = MyStringLen(name);
|
||||
unsigned propsLen = MyStringLen(s);
|
||||
const unsigned nameLen = MyStringLen(name);
|
||||
const unsigned propsLen = MyStringLen(s);
|
||||
unsigned totalLen = nameLen + propsLen;
|
||||
if (propsLen != 0)
|
||||
totalLen++;
|
||||
@@ -523,7 +538,7 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
|
||||
pos -= ConvertMethodIdToString_Back(temp + pos, id64);
|
||||
else
|
||||
{
|
||||
unsigned len = methodName.Len();
|
||||
const unsigned len = methodName.Len();
|
||||
if (len + 5 > pos)
|
||||
break;
|
||||
pos -= len;
|
||||
@@ -547,9 +562,9 @@ HRESULT CHandler::SetMethodToProp(CNum folderIndex, PROPVARIANT *prop) const
|
||||
|
||||
#endif
|
||||
|
||||
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value))
|
||||
{
|
||||
RINOK(PropVariant_Clear(value));
|
||||
RINOK(PropVariant_Clear(value))
|
||||
// COM_TRY_BEGIN
|
||||
// NCOM::CPropVariant prop;
|
||||
|
||||
@@ -576,7 +591,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
{
|
||||
// prop = ref2.PackSize;
|
||||
{
|
||||
CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
|
||||
const CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
|
||||
if (folderIndex != kNumNoIndex)
|
||||
{
|
||||
if (_db.FolderStartFileIndex[folderIndex] == (CNum)index2)
|
||||
@@ -617,24 +632,24 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
|
||||
case kpidPath: return _db.GetPath_Prop(index, value);
|
||||
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
|
||||
case kpidMethod: return SetMethodToProp(_db.FileIndexToFolderIndexMap[index2], value);
|
||||
case kpidBlock:
|
||||
{
|
||||
CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
|
||||
const CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
|
||||
if (folderIndex != kNumNoIndex)
|
||||
PropVarEm_Set_UInt32(value, (UInt32)folderIndex);
|
||||
}
|
||||
break;
|
||||
/*
|
||||
#ifdef Z7_7Z_SHOW_PACK_STREAMS_SIZES
|
||||
case kpidPackedSize0:
|
||||
case kpidPackedSize1:
|
||||
case kpidPackedSize2:
|
||||
case kpidPackedSize3:
|
||||
case kpidPackedSize4:
|
||||
{
|
||||
CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
|
||||
const CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
|
||||
if (folderIndex != kNumNoIndex)
|
||||
{
|
||||
if (_db.FolderStartFileIndex[folderIndex] == (CNum)index2 &&
|
||||
@@ -648,7 +663,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
PropVarEm_Set_UInt64(value, 0);
|
||||
}
|
||||
break;
|
||||
*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -657,13 +672,13 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
// COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
Z7_COM7F_IMF(CHandler::Open(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
IArchiveOpenCallback *openArchiveCallback)
|
||||
IArchiveOpenCallback *openArchiveCallback))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
Close();
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
_fileInfoPopIDs.Clear();
|
||||
#endif
|
||||
|
||||
@@ -671,31 +686,31 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
{
|
||||
CMyComPtr<IArchiveOpenCallback> openArchiveCallbackTemp = openArchiveCallback;
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
CMyComPtr<ICryptoGetTextPassword> getTextPassword;
|
||||
if (openArchiveCallback)
|
||||
openArchiveCallbackTemp.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
|
||||
#endif
|
||||
|
||||
CInArchive archive(
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
#ifdef Z7_7Z_SET_PROPERTIES
|
||||
_useMultiThreadMixer
|
||||
#else
|
||||
true
|
||||
#endif
|
||||
);
|
||||
_db.IsArc = false;
|
||||
RINOK(archive.Open(stream, maxCheckStartPosition));
|
||||
RINOK(archive.Open(stream, maxCheckStartPosition))
|
||||
_db.IsArc = true;
|
||||
|
||||
HRESULT result = archive.ReadDatabase(
|
||||
EXTERNAL_CODECS_VARS
|
||||
_db
|
||||
#ifndef _NO_CRYPTO
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
, getTextPassword, _isEncrypted, _passwordIsDefined, _password
|
||||
#endif
|
||||
);
|
||||
RINOK(result);
|
||||
RINOK(result)
|
||||
|
||||
_inStream = stream;
|
||||
}
|
||||
@@ -708,19 +723,19 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
// _inStream = stream;
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
FillPopIDs();
|
||||
#endif
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
Z7_COM7F_IMF(CHandler::Close())
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
_inStream.Release();
|
||||
_db.Clear();
|
||||
#ifndef _NO_CRYPTO
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
_isEncrypted = false;
|
||||
_passwordIsDefined = false;
|
||||
_password.Wipe_and_Empty();
|
||||
@@ -729,10 +744,10 @@ STDMETHODIMP CHandler::Close()
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
#ifdef EXTRACT_ONLY
|
||||
#ifdef Z7_7Z_SET_PROPERTIES
|
||||
#ifdef Z7_EXTRACT_ONLY
|
||||
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
|
||||
Z7_COM7F_IMF(CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
@@ -747,19 +762,19 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
||||
return E_INVALIDARG;
|
||||
const PROPVARIANT &value = values[i];
|
||||
UInt32 number;
|
||||
unsigned index = ParseStringToUInt32(name, number);
|
||||
const unsigned index = ParseStringToUInt32(name, number);
|
||||
if (index == 0)
|
||||
{
|
||||
if (name.IsEqualTo("mtf"))
|
||||
{
|
||||
RINOK(PROPVARIANT_to_bool(value, _useMultiThreadMixer));
|
||||
RINOK(PROPVARIANT_to_bool(value, _useMultiThreadMixer))
|
||||
continue;
|
||||
}
|
||||
{
|
||||
HRESULT hres;
|
||||
if (SetCommonProperty(name, value, hres))
|
||||
{
|
||||
RINOK(hres);
|
||||
RINOK(hres)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
// 7z/Handler.h
|
||||
|
||||
#ifndef __7Z_HANDLER_H
|
||||
#define __7Z_HANDLER_H
|
||||
#ifndef ZIP7_7Z_HANDLER_H
|
||||
#define ZIP7_7Z_HANDLER_H
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../IArchive.h"
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
#ifndef __7Z_SET_PROPERTIES
|
||||
#ifndef Z7_7Z_SET_PROPERTIES
|
||||
|
||||
#ifdef EXTRACT_ONLY
|
||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
||||
#define __7Z_SET_PROPERTIES
|
||||
#ifdef Z7_EXTRACT_ONLY
|
||||
#if !defined(Z7_ST) && !defined(Z7_SFX)
|
||||
#define Z7_7Z_SET_PROPERTIES
|
||||
#endif
|
||||
#else
|
||||
#define __7Z_SET_PROPERTIES
|
||||
#define Z7_7Z_SET_PROPERTIES
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// #ifdef __7Z_SET_PROPERTIES
|
||||
// #ifdef Z7_7Z_SET_PROPERTIES
|
||||
#include "../Common/HandlerOut.h"
|
||||
// #endif
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
#ifndef Z7_EXTRACT_ONLY
|
||||
|
||||
class COutHandler: public CMultiMethodProps
|
||||
{
|
||||
@@ -79,73 +79,63 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
class CHandler:
|
||||
class CHandler Z7_final:
|
||||
public IInArchive,
|
||||
public IArchiveGetRawProps,
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
#ifdef Z7_7Z_SET_PROPERTIES
|
||||
public ISetProperties,
|
||||
#endif
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
#ifndef Z7_EXTRACT_ONLY
|
||||
public IOutArchive,
|
||||
#endif
|
||||
|
||||
PUBLIC_ISetCompressCodecsInfo
|
||||
Z7_PUBLIC_ISetCompressCodecsInfo_IFEC
|
||||
|
||||
public CMyUnknownImp,
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
#ifndef Z7_EXTRACT_ONLY
|
||||
public COutHandler
|
||||
#else
|
||||
public CCommonMethodProps
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps)
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
#endif
|
||||
#ifndef EXTRACT_ONLY
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
#endif
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
INTERFACE_IInArchive(;)
|
||||
INTERFACE_IArchiveGetRawProps(;)
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
STDMETHOD(SetProperties)(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
|
||||
#endif
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
INTERFACE_IOutArchive(;)
|
||||
#endif
|
||||
Z7_COM_QI_BEGIN2(IInArchive)
|
||||
Z7_COM_QI_ENTRY(IArchiveGetRawProps)
|
||||
#ifdef Z7_7Z_SET_PROPERTIES
|
||||
Z7_COM_QI_ENTRY(ISetProperties)
|
||||
#endif
|
||||
#ifndef Z7_EXTRACT_ONLY
|
||||
Z7_COM_QI_ENTRY(IOutArchive)
|
||||
#endif
|
||||
Z7_COM_QI_ENTRY_ISetCompressCodecsInfo_IFEC
|
||||
Z7_COM_QI_END
|
||||
Z7_COM_ADDREF_RELEASE
|
||||
|
||||
Z7_IFACE_COM7_IMP(IInArchive)
|
||||
Z7_IFACE_COM7_IMP(IArchiveGetRawProps)
|
||||
#ifdef Z7_7Z_SET_PROPERTIES
|
||||
Z7_IFACE_COM7_IMP(ISetProperties)
|
||||
#endif
|
||||
#ifndef Z7_EXTRACT_ONLY
|
||||
Z7_IFACE_COM7_IMP(IOutArchive)
|
||||
#endif
|
||||
DECL_ISetCompressCodecsInfo
|
||||
|
||||
CHandler();
|
||||
~CHandler()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private:
|
||||
CMyComPtr<IInStream> _inStream;
|
||||
NArchive::N7z::CDbEx _db;
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
bool _isEncrypted;
|
||||
bool _passwordIsDefined;
|
||||
UString _password; // _Wipe
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef EXTRACT_ONLY
|
||||
#ifdef Z7_EXTRACT_ONLY
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
#ifdef Z7_7Z_SET_PROPERTIES
|
||||
bool _useMultiThreadMixer;
|
||||
#endif
|
||||
|
||||
@@ -162,7 +152,7 @@ private:
|
||||
#endif
|
||||
|
||||
bool IsFolderEncrypted(CNum folderIndex) const;
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
|
||||
CRecordVector<UInt64> _fileInfoPopIDs;
|
||||
void FillPopIDs();
|
||||
@@ -172,6 +162,13 @@ private:
|
||||
#endif
|
||||
|
||||
DECL_EXTERNAL_CODECS_VARS
|
||||
|
||||
public:
|
||||
CHandler();
|
||||
~CHandler()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "7zOut.h"
|
||||
#include "7zUpdate.h"
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
#ifndef Z7_EXTRACT_ONLY
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
@@ -35,7 +35,7 @@ static const UInt32 k_Dictionary_ForHeaders =
|
||||
1 << 20;
|
||||
#endif
|
||||
|
||||
STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
|
||||
Z7_COM7F_IMF(CHandler::GetFileTimeType(UInt32 *type))
|
||||
{
|
||||
*type = NFileTimeType::kWindows;
|
||||
return S_OK;
|
||||
@@ -43,10 +43,11 @@ STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
|
||||
|
||||
HRESULT CHandler::PropsMethod_To_FullMethod(CMethodFull &dest, const COneMethodInfo &m)
|
||||
{
|
||||
bool isFilter;
|
||||
dest.CodecIndex = FindMethod_Index(
|
||||
EXTERNAL_CODECS_VARS
|
||||
m.MethodName, true,
|
||||
dest.Id, dest.NumStreams);
|
||||
dest.Id, dest.NumStreams, isFilter);
|
||||
if (dest.CodecIndex < 0)
|
||||
return E_INVALIDARG;
|
||||
(CProps &)dest = (CProps &)m;
|
||||
@@ -118,7 +119,7 @@ HRESULT CHandler::SetMainMethod(CCompressionMethodMode &methodMode)
|
||||
|
||||
SetGlobalLevelTo(oneMethodInfo);
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
const bool numThreads_WasSpecifiedInMethod = (oneMethodInfo.Get_NumThreads() >= 0);
|
||||
if (!numThreads_WasSpecifiedInMethod)
|
||||
{
|
||||
@@ -128,9 +129,9 @@ HRESULT CHandler::SetMainMethod(CCompressionMethodMode &methodMode)
|
||||
#endif
|
||||
|
||||
CMethodFull &methodFull = methodMode.Methods.AddNew();
|
||||
RINOK(PropsMethod_To_FullMethod(methodFull, oneMethodInfo));
|
||||
RINOK(PropsMethod_To_FullMethod(methodFull, oneMethodInfo))
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
methodFull.Set_NumThreads = true;
|
||||
methodFull.NumThreads = methodMode.NumThreads;
|
||||
#endif
|
||||
@@ -147,15 +148,55 @@ HRESULT CHandler::SetMainMethod(CCompressionMethodMode &methodMode)
|
||||
case k_Deflate: dicSize = (UInt32)1 << 15; break;
|
||||
case k_Deflate64: dicSize = (UInt32)1 << 16; break;
|
||||
case k_BZip2: dicSize = oneMethodInfo.Get_BZip2_BlockSize(); break;
|
||||
// case k_ZSTD: dicSize = 1 << 23; break;
|
||||
default: continue;
|
||||
}
|
||||
|
||||
UInt64 numSolidBytes;
|
||||
|
||||
|
||||
/*
|
||||
if (methodFull.Id == k_ZSTD)
|
||||
{
|
||||
// continue;
|
||||
NCompress::NZstd::CEncoderProps encoderProps;
|
||||
RINOK(oneMethodInfo.Set_PropsTo_zstd(encoderProps));
|
||||
CZstdEncProps &zstdProps = encoderProps.EncProps;
|
||||
ZstdEncProps_NormalizeFull(&zstdProps);
|
||||
UInt64 cs = (UInt64)(zstdProps.jobSize);
|
||||
UInt32 winSize = (UInt32)(1 << zstdProps.windowLog);
|
||||
if (cs < winSize)
|
||||
cs = winSize;
|
||||
numSolidBytes = cs << 6;
|
||||
const UInt64 kSolidBytes_Zstd_Max = ((UInt64)1 << 34);
|
||||
if (numSolidBytes > kSolidBytes_Zstd_Max)
|
||||
numSolidBytes = kSolidBytes_Zstd_Max;
|
||||
|
||||
methodFull.Set_NumThreads = false; // we don't use ICompressSetCoderMt::SetNumberOfThreads() for LZMA2 encoder
|
||||
|
||||
#ifndef Z7_ST
|
||||
if (!numThreads_WasSpecifiedInMethod
|
||||
&& !methodMode.NumThreads_WasForced
|
||||
&& methodMode.MemoryUsageLimit_WasSet
|
||||
)
|
||||
{
|
||||
const UInt32 numThreads_Original = methodMode.NumThreads;
|
||||
const UInt32 numThreads_New = ZstdEncProps_GetNumThreads_for_MemUsageLimit(
|
||||
&zstdProps,
|
||||
methodMode.MemoryUsageLimit,
|
||||
numThreads_Original);
|
||||
if (numThreads_Original != numThreads_New)
|
||||
{
|
||||
CMultiMethodProps::SetMethodThreadsTo_Replace(methodFull, numThreads_New);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
*/
|
||||
if (methodFull.Id == k_LZMA2)
|
||||
{
|
||||
// he we calculate default chunk Size for LZMA2 as defined in LZMA2 encoder code
|
||||
/* lzma2 code use dictionary upo to fake 4 GiB to calculate ChunkSize.
|
||||
/* lzma2 code use dictionary up to fake 4 GiB to calculate ChunkSize.
|
||||
So we do same */
|
||||
UInt64 cs = (UInt64)dicSize << 2;
|
||||
const UInt32 kMinSize = (UInt32)1 << 20;
|
||||
@@ -167,10 +208,10 @@ HRESULT CHandler::SetMainMethod(CCompressionMethodMode &methodMode)
|
||||
cs &= ~(UInt64)(kMinSize - 1);
|
||||
// we want to use at least 64 chunks (threads) per one solid block.
|
||||
|
||||
// here we don't use chunckSize property
|
||||
// here we don't use chunkSize property
|
||||
numSolidBytes = cs << 6;
|
||||
|
||||
// here we get real chunckSize
|
||||
// here we get real chunkSize
|
||||
cs = oneMethodInfo.Get_Xz_BlockSize();
|
||||
if (dicSize > cs)
|
||||
dicSize = cs;
|
||||
@@ -181,7 +222,7 @@ HRESULT CHandler::SetMainMethod(CCompressionMethodMode &methodMode)
|
||||
|
||||
methodFull.Set_NumThreads = false; // we don't use ICompressSetCoderMt::SetNumberOfThreads() for LZMA2 encoder
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
if (!numThreads_WasSpecifiedInMethod
|
||||
&& !methodMode.NumThreads_WasForced
|
||||
&& methodMode.MemoryUsageLimit_WasSet
|
||||
@@ -261,7 +302,7 @@ static HRESULT GetTime(IArchiveUpdateCallback *updateCallback, unsigned index, P
|
||||
// ft = 0;
|
||||
// ftDefined = false;
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(updateCallback->GetProperty(index, propID, &prop));
|
||||
RINOK(updateCallback->GetProperty(index, propID, &prop))
|
||||
if (prop.vt == VT_FILETIME)
|
||||
{
|
||||
ft = prop.filetime.dwLowDateTime | ((UInt64)prop.filetime.dwHighDateTime << 32);
|
||||
@@ -344,13 +385,13 @@ static int AddFolder(CObjectVector<CTreeFolder> &treeFolders, int cur, const USt
|
||||
}
|
||||
*/
|
||||
|
||||
STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
|
||||
IArchiveUpdateCallback *updateCallback)
|
||||
Z7_COM7F_IMF(CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
|
||||
IArchiveUpdateCallback *updateCallback))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
const CDbEx *db = 0;
|
||||
#ifdef _7Z_VOL
|
||||
const CDbEx *db = NULL;
|
||||
#ifdef Z7_7Z_VOL
|
||||
if (_volumes.Size() > 1)
|
||||
return E_FAIL;
|
||||
const CVolume *volume = 0;
|
||||
@@ -360,7 +401,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
db = &volume->Database;
|
||||
}
|
||||
#else
|
||||
if (_inStream != 0)
|
||||
if (_inStream)
|
||||
db = &_db;
|
||||
#endif
|
||||
|
||||
@@ -368,8 +409,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
return E_NOTIMPL;
|
||||
|
||||
/*
|
||||
CMyComPtr<IArchiveGetRawProps> getRawProps;
|
||||
updateCallback->QueryInterface(IID_IArchiveGetRawProps, (void **)&getRawProps);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
IArchiveGetRawProps,
|
||||
getRawProps, updateCallback)
|
||||
|
||||
CUniqBlocks secureBlocks;
|
||||
secureBlocks.AddUniq(NULL, 0);
|
||||
@@ -406,7 +448,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
UInt32 indexInArchive;
|
||||
if (!updateCallback)
|
||||
return E_FAIL;
|
||||
RINOK(updateCallback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArchive));
|
||||
RINOK(updateCallback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArchive))
|
||||
CUpdateItem ui;
|
||||
ui.NewProps = IntToBool(newProps);
|
||||
ui.NewData = IntToBool(newData);
|
||||
@@ -445,7 +487,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
if (need_Attrib)
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(updateCallback->GetProperty(i, kpidAttrib, &prop));
|
||||
RINOK(updateCallback->GetProperty(i, kpidAttrib, &prop))
|
||||
if (prop.vt == VT_EMPTY)
|
||||
ui.AttribDefined = false;
|
||||
else if (prop.vt != VT_UI4)
|
||||
@@ -458,9 +500,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
}
|
||||
|
||||
// we need MTime to sort files.
|
||||
if (need_CTime) RINOK(GetTime(updateCallback, i, kpidCTime, ui.CTime, ui.CTimeDefined));
|
||||
if (need_ATime) RINOK(GetTime(updateCallback, i, kpidATime, ui.ATime, ui.ATimeDefined));
|
||||
if (need_MTime) RINOK(GetTime(updateCallback, i, kpidMTime, ui.MTime, ui.MTimeDefined));
|
||||
if (need_CTime) RINOK(GetTime(updateCallback, i, kpidCTime, ui.CTime, ui.CTimeDefined))
|
||||
if (need_ATime) RINOK(GetTime(updateCallback, i, kpidATime, ui.ATime, ui.ATimeDefined))
|
||||
if (need_MTime) RINOK(GetTime(updateCallback, i, kpidMTime, ui.MTime, ui.MTimeDefined))
|
||||
|
||||
/*
|
||||
if (getRawProps)
|
||||
@@ -478,7 +520,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(updateCallback->GetProperty(i, kpidPath, &prop));
|
||||
RINOK(updateCallback->GetProperty(i, kpidPath, &prop))
|
||||
if (prop.vt == VT_EMPTY)
|
||||
{
|
||||
}
|
||||
@@ -492,7 +534,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
}
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(updateCallback->GetProperty(i, kpidIsDir, &prop));
|
||||
RINOK(updateCallback->GetProperty(i, kpidIsDir, &prop))
|
||||
if (prop.vt == VT_EMPTY)
|
||||
folderStatusIsDefined = false;
|
||||
else if (prop.vt != VT_BOOL)
|
||||
@@ -506,7 +548,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(updateCallback->GetProperty(i, kpidIsAnti, &prop));
|
||||
RINOK(updateCallback->GetProperty(i, kpidIsAnti, &prop))
|
||||
if (prop.vt == VT_EMPTY)
|
||||
ui.IsAnti = false;
|
||||
else if (prop.vt != VT_BOOL)
|
||||
@@ -623,7 +665,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
if (!ui.IsDir)
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(updateCallback->GetProperty(i, kpidSize, &prop));
|
||||
RINOK(updateCallback->GetProperty(i, kpidSize, &prop))
|
||||
if (prop.vt != VT_UI8)
|
||||
return E_INVALIDARG;
|
||||
ui.Size = (UInt64)prop.uhVal.QuadPart;
|
||||
@@ -650,7 +692,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
methodMode.MemoryUsageLimit = _memUsage_Compress;
|
||||
methodMode.MemoryUsageLimit_WasSet = _memUsage_WasSet;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
{
|
||||
UInt32 numThreads = _numThreads;
|
||||
const UInt32 kNumThreads_Max = 1024;
|
||||
@@ -664,13 +706,14 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT res = SetMainMethod(methodMode);
|
||||
RINOK(res);
|
||||
const HRESULT res = SetMainMethod(methodMode);
|
||||
RINOK(res)
|
||||
|
||||
RINOK(SetHeaderMethod(headerMethod));
|
||||
RINOK(SetHeaderMethod(headerMethod))
|
||||
|
||||
CMyComPtr<ICryptoGetTextPassword2> getPassword2;
|
||||
updateCallback->QueryInterface(IID_ICryptoGetTextPassword2, (void **)&getPassword2);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(
|
||||
ICryptoGetTextPassword2,
|
||||
getPassword2, updateCallback)
|
||||
|
||||
methodMode.PasswordIsDefined = false;
|
||||
methodMode.Password.Wipe_and_Empty();
|
||||
@@ -678,7 +721,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
{
|
||||
CMyComBSTR_Wipe password;
|
||||
Int32 passwordIsDefined;
|
||||
RINOK(getPassword2->CryptoGetTextPassword2(&passwordIsDefined, &password));
|
||||
RINOK(getPassword2->CryptoGetTextPassword2(&passwordIsDefined, &password))
|
||||
methodMode.PasswordIsDefined = IntToBool(passwordIsDefined);
|
||||
if (methodMode.PasswordIsDefined && password)
|
||||
methodMode.Password = password;
|
||||
@@ -688,7 +731,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
|
||||
bool encryptHeaders = false;
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
if (!methodMode.PasswordIsDefined && _passwordIsDefined)
|
||||
{
|
||||
// if header is compressed, we use that password for updated archive
|
||||
@@ -701,7 +744,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
{
|
||||
if (_encryptHeadersSpecified)
|
||||
encryptHeaders = _encryptHeaders;
|
||||
#ifndef _NO_CRYPTO
|
||||
#ifndef Z7_NO_CRYPTO
|
||||
else
|
||||
encryptHeaders = _passwordIsDefined;
|
||||
#endif
|
||||
@@ -716,13 +759,14 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
if (numItems < 2)
|
||||
compressMainHeader = false;
|
||||
|
||||
int level = GetLevel();
|
||||
const int level = GetLevel();
|
||||
|
||||
CUpdateOptions options;
|
||||
options.Need_CTime = need_CTime;
|
||||
options.Need_ATime = need_ATime;
|
||||
options.Need_MTime = need_MTime;
|
||||
options.Need_Attrib = need_Attrib;
|
||||
// options.Need_Crc = (_crcSize != 0); // for debug
|
||||
|
||||
options.Method = &methodMode;
|
||||
options.HeaderMethod = (_compressHeaders || encryptHeaders) ? &headerMethod : NULL;
|
||||
@@ -748,12 +792,6 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
|
||||
options.MultiThreadMixer = _useMultiThreadMixer;
|
||||
|
||||
COutArchive archive;
|
||||
CArchiveDatabaseOut newDatabase;
|
||||
|
||||
CMyComPtr<ICryptoGetTextPassword> getPassword;
|
||||
updateCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getPassword);
|
||||
|
||||
/*
|
||||
if (secureBlocks.Sorted.Size() > 1)
|
||||
{
|
||||
@@ -766,9 +804,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
}
|
||||
*/
|
||||
|
||||
res = Update(
|
||||
return Update(
|
||||
EXTERNAL_CODECS_VARS
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
volume ? volume->Stream: 0,
|
||||
volume ? db : 0,
|
||||
#else
|
||||
@@ -778,18 +816,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
updateItems,
|
||||
// treeFolders,
|
||||
// secureBlocks,
|
||||
archive, newDatabase, outStream, updateCallback, options
|
||||
#ifndef _NO_CRYPTO
|
||||
, getPassword
|
||||
#endif
|
||||
);
|
||||
|
||||
RINOK(res);
|
||||
|
||||
updateItems.ClearAndFree();
|
||||
|
||||
return archive.WriteDatabase(EXTERNAL_CODECS_VARS
|
||||
newDatabase, options.HeaderMethod, options.HeaderOptions);
|
||||
outStream, updateCallback, options);
|
||||
|
||||
COM_TRY_END
|
||||
}
|
||||
@@ -798,7 +825,7 @@ static HRESULT ParseBond(UString &srcString, UInt32 &coder, UInt32 &stream)
|
||||
{
|
||||
stream = 0;
|
||||
{
|
||||
unsigned index = ParseStringToUInt32(srcString, coder);
|
||||
const unsigned index = ParseStringToUInt32(srcString, coder);
|
||||
if (index == 0)
|
||||
return E_INVALIDARG;
|
||||
srcString.DeleteFrontal(index);
|
||||
@@ -806,7 +833,7 @@ static HRESULT ParseBond(UString &srcString, UInt32 &coder, UInt32 &stream)
|
||||
if (srcString[0] == 's')
|
||||
{
|
||||
srcString.Delete(0);
|
||||
unsigned index = ParseStringToUInt32(srcString, stream);
|
||||
const unsigned index = ParseStringToUInt32(srcString, stream);
|
||||
if (index == 0)
|
||||
return E_INVALIDARG;
|
||||
srcString.DeleteFrontal(index);
|
||||
@@ -860,7 +887,7 @@ HRESULT COutHandler::SetSolidFromString(const UString &s)
|
||||
i += (unsigned)(end - start);
|
||||
if (i == s2.Len())
|
||||
return E_INVALIDARG;
|
||||
wchar_t c = s2[i++];
|
||||
const wchar_t c = s2[i++];
|
||||
if (c == 'f')
|
||||
{
|
||||
if (v < 1)
|
||||
@@ -912,7 +939,7 @@ HRESULT COutHandler::SetSolidFromPROPVARIANT(const PROPVARIANT &value)
|
||||
|
||||
static HRESULT PROPVARIANT_to_BoolPair(const PROPVARIANT &prop, CBoolPair &dest)
|
||||
{
|
||||
RINOK(PROPVARIANT_to_bool(prop, dest.Val));
|
||||
RINOK(PROPVARIANT_to_bool(prop, dest.Val))
|
||||
dest.Def = true;
|
||||
return S_OK;
|
||||
}
|
||||
@@ -935,7 +962,7 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
|
||||
}
|
||||
|
||||
UInt32 number;
|
||||
unsigned index = ParseStringToUInt32(name, number);
|
||||
const unsigned index = ParseStringToUInt32(name, number);
|
||||
// UString realName = name.Ptr(index);
|
||||
if (index == 0)
|
||||
{
|
||||
@@ -946,20 +973,20 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
|
||||
if (name.IsEqualTo("hcf"))
|
||||
{
|
||||
bool compressHeadersFull = true;
|
||||
RINOK(PROPVARIANT_to_bool(value, compressHeadersFull));
|
||||
RINOK(PROPVARIANT_to_bool(value, compressHeadersFull))
|
||||
return compressHeadersFull ? S_OK: E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (name.IsEqualTo("he"))
|
||||
{
|
||||
RINOK(PROPVARIANT_to_bool(value, _encryptHeaders));
|
||||
RINOK(PROPVARIANT_to_bool(value, _encryptHeaders))
|
||||
_encryptHeadersSpecified = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
{
|
||||
bool processed;
|
||||
RINOK(TimeOptions.Parse(name, value, processed));
|
||||
RINOK(TimeOptions.Parse(name, value, processed))
|
||||
if (processed)
|
||||
{
|
||||
if ( TimeOptions.Prec != (UInt32)(Int32)-1
|
||||
@@ -982,7 +1009,7 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
|
||||
return CMultiMethodProps::SetProperty(name, value);
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
|
||||
Z7_COM7F_IMF(CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
_bonds.Clear();
|
||||
@@ -997,6 +1024,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
||||
|
||||
const PROPVARIANT &value = values[i];
|
||||
|
||||
if (name.Find(L':') >= 0) // 'b' was used as NCoderPropID::kBlockSize2 before v23
|
||||
if (name[0] == 'b')
|
||||
{
|
||||
if (value.vt != VT_EMPTY)
|
||||
@@ -1004,12 +1032,12 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
||||
name.Delete(0);
|
||||
|
||||
CBond2 bond;
|
||||
RINOK(ParseBond(name, bond.OutCoder, bond.OutStream));
|
||||
RINOK(ParseBond(name, bond.OutCoder, bond.OutStream))
|
||||
if (name[0] != ':')
|
||||
return E_INVALIDARG;
|
||||
name.Delete(0);
|
||||
UInt32 inStream = 0;
|
||||
RINOK(ParseBond(name, bond.InCoder, inStream));
|
||||
RINOK(ParseBond(name, bond.InCoder, inStream))
|
||||
if (inStream != 0)
|
||||
return E_INVALIDARG;
|
||||
if (!name.IsEmpty())
|
||||
@@ -1018,7 +1046,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
||||
continue;
|
||||
}
|
||||
|
||||
RINOK(SetProperty(name, value));
|
||||
RINOK(SetProperty(name, value))
|
||||
}
|
||||
|
||||
unsigned numEmptyMethods = GetNumEmptyMethods();
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
Byte kSignature[kSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
Byte kFinishSignature[kSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C + 1};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 7z/7zHeader.h
|
||||
|
||||
#ifndef __7Z_HEADER_H
|
||||
#define __7Z_HEADER_H
|
||||
#ifndef ZIP7_INC_7Z_HEADER_H
|
||||
#define ZIP7_INC_7Z_HEADER_H
|
||||
|
||||
#include "../../../Common/MyTypes.h"
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace N7z {
|
||||
const unsigned kSignatureSize = 6;
|
||||
extern Byte kSignature[kSignatureSize];
|
||||
|
||||
// #define _7Z_VOL
|
||||
// #define Z7_7Z_VOL
|
||||
// 7z-MultiVolume is not finished yet.
|
||||
// It can work already, but I still do not like some
|
||||
// things of that new multivolume format.
|
||||
// So please keep it commented.
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
extern Byte kFinishSignature[kSignatureSize];
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ struct CStartHeader
|
||||
|
||||
const UInt32 kStartHeaderSize = 20;
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
struct CFinishHeader: public CStartHeader
|
||||
{
|
||||
UInt64 ArchiveStartOffset; // data offset from end if that struct
|
||||
@@ -99,6 +99,7 @@ namespace NID
|
||||
|
||||
const UInt32 k_Copy = 0;
|
||||
const UInt32 k_Delta = 3;
|
||||
const UInt32 k_ARM64 = 0xa;
|
||||
|
||||
const UInt32 k_LZMA2 = 0x21;
|
||||
|
||||
@@ -122,14 +123,17 @@ const UInt32 k_SPARC = 0x3030805;
|
||||
|
||||
const UInt32 k_AES = 0x6F10701;
|
||||
|
||||
// const UInt32 k_ZSTD = 0x4015D; // winzip zstd
|
||||
// 0x4F71101, 7z-zstd
|
||||
|
||||
static inline bool IsFilterMethod(UInt64 m)
|
||||
{
|
||||
if (m > (UInt64)0xFFFFFFFF)
|
||||
if (m > (UInt32)0xFFFFFFFF)
|
||||
return false;
|
||||
switch ((UInt32)m)
|
||||
{
|
||||
case k_Delta:
|
||||
case k_ARM64:
|
||||
case k_BCJ:
|
||||
case k_BCJ2:
|
||||
case k_PPC:
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "../../../../C/7zCrc.h"
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
#include "../../../Common/MyBuffer2.h"
|
||||
// #include "../../../Common/UTFConvert.h"
|
||||
|
||||
#include "../../Common/StreamObjects.h"
|
||||
@@ -24,7 +25,7 @@
|
||||
#define Get64(p) GetUi64(p)
|
||||
|
||||
// define FORMAT_7Z_RECOVERY if you want to recover multivolume archives with empty StartHeader
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
#define FORMAT_7Z_RECOVERY
|
||||
#endif
|
||||
|
||||
@@ -34,6 +35,9 @@ using namespace NCOM;
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
#define k_Scan_NumCoders_MAX 64
|
||||
#define k_Scan_NumCodersStreams_in_Folder_MAX 64
|
||||
|
||||
unsigned BoolVector_CountSum(const CBoolVector &v);
|
||||
unsigned BoolVector_CountSum(const CBoolVector &v)
|
||||
{
|
||||
@@ -62,13 +66,13 @@ static void BoolVector_Fill_False(CBoolVector &v, unsigned size)
|
||||
class CInArchiveException {};
|
||||
class CUnsupportedFeatureException: public CInArchiveException {};
|
||||
|
||||
MY_ATTR_NORETURN
|
||||
Z7_ATTR_NORETURN
|
||||
static void ThrowException() { throw CInArchiveException(); }
|
||||
MY_ATTR_NORETURN
|
||||
Z7_ATTR_NORETURN
|
||||
static inline void ThrowEndOfData() { ThrowException(); }
|
||||
MY_ATTR_NORETURN
|
||||
Z7_ATTR_NORETURN
|
||||
static inline void ThrowUnsupported() { throw CUnsupportedFeatureException(); }
|
||||
MY_ATTR_NORETURN
|
||||
Z7_ATTR_NORETURN
|
||||
static inline void ThrowIncorrect() { ThrowException(); }
|
||||
|
||||
class CStreamSwitch
|
||||
@@ -113,12 +117,12 @@ void CStreamSwitch::Set(CInArchive *archive, const CByteBuffer &byteBuffer)
|
||||
void CStreamSwitch::Set(CInArchive *archive, const CObjectVector<CByteBuffer> *dataVector)
|
||||
{
|
||||
Remove();
|
||||
Byte external = archive->ReadByte();
|
||||
const Byte external = archive->ReadByte();
|
||||
if (external != 0)
|
||||
{
|
||||
if (!dataVector)
|
||||
ThrowIncorrect();
|
||||
CNum dataIndex = archive->ReadNum();
|
||||
const CNum dataIndex = archive->ReadNum();
|
||||
if (dataIndex >= dataVector->Size())
|
||||
ThrowIncorrect();
|
||||
Set(archive, (*dataVector)[dataIndex]);
|
||||
@@ -171,7 +175,7 @@ static UInt64 ReadNumberSpec(const Byte *p, size_t size, size_t &processed)
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned b = *p++;
|
||||
const unsigned b = *p++;
|
||||
size--;
|
||||
|
||||
if ((b & 0x80) == 0)
|
||||
@@ -192,10 +196,10 @@ static UInt64 ReadNumberSpec(const Byte *p, size_t size, size_t &processed)
|
||||
|
||||
for (unsigned i = 1; i < 8; i++)
|
||||
{
|
||||
unsigned mask = (unsigned)0x80 >> i;
|
||||
const unsigned mask = (unsigned)0x80 >> i;
|
||||
if ((b & mask) == 0)
|
||||
{
|
||||
UInt64 high = b & (mask - 1);
|
||||
const UInt64 high = b & (mask - 1);
|
||||
value |= (high << (i * 8));
|
||||
processed = i + 1;
|
||||
return value;
|
||||
@@ -219,7 +223,7 @@ static UInt64 ReadNumberSpec(const Byte *p, size_t size, size_t &processed)
|
||||
UInt64 CInByte2::ReadNumber()
|
||||
{
|
||||
size_t processed;
|
||||
UInt64 res = ReadNumberSpec(_buffer + _pos, _size - _pos, processed);
|
||||
const UInt64 res = ReadNumberSpec(_buffer + _pos, _size - _pos, processed);
|
||||
if (processed == 0)
|
||||
ThrowEndOfData();
|
||||
_pos += processed;
|
||||
@@ -239,7 +243,7 @@ CNum CInByte2::ReadNum()
|
||||
}
|
||||
}
|
||||
*/
|
||||
UInt64 value = ReadNumber();
|
||||
const UInt64 value = ReadNumber();
|
||||
if (value > kNumMax)
|
||||
ThrowUnsupported();
|
||||
return (CNum)value;
|
||||
@@ -249,7 +253,7 @@ UInt32 CInByte2::ReadUInt32()
|
||||
{
|
||||
if (_pos + 4 > _size)
|
||||
ThrowEndOfData();
|
||||
UInt32 res = Get32(_buffer + _pos);
|
||||
const UInt32 res = Get32(_buffer + _pos);
|
||||
_pos += 4;
|
||||
return res;
|
||||
}
|
||||
@@ -258,54 +262,101 @@ UInt64 CInByte2::ReadUInt64()
|
||||
{
|
||||
if (_pos + 8 > _size)
|
||||
ThrowEndOfData();
|
||||
UInt64 res = Get64(_buffer + _pos);
|
||||
const UInt64 res = Get64(_buffer + _pos);
|
||||
_pos += 8;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define CHECK_SIGNATURE if (p[0] != '7' || p[1] != 'z' || p[2] != 0xBC || p[3] != 0xAF || p[4] != 0x27 || p[5] != 0x1C) return false;
|
||||
#define Y0 '7'
|
||||
#define Y1 'z'
|
||||
#define Y2 0xBC
|
||||
#define Y3 0xAF
|
||||
#define Y4 0x27
|
||||
#define Y5 0x1C
|
||||
|
||||
static inline bool TestSignature(const Byte *p)
|
||||
#define IS_SIGNATURE(p)( \
|
||||
(p)[2] == Y2 && \
|
||||
(p)[3] == Y3 && \
|
||||
(p)[5] == Y5 && \
|
||||
(p)[4] == Y4 && \
|
||||
(p)[1] == Y1 && \
|
||||
(p)[0] == Y0)
|
||||
|
||||
/* FindSignature_10() is allowed to access data up to and including &limit[9].
|
||||
limit[10] access is not allowed.
|
||||
return:
|
||||
(return_ptr < limit) : signature was found at (return_ptr)
|
||||
(return_ptr >= limit) : limit was reached or crossed. So no signature found before limit
|
||||
*/
|
||||
Z7_NO_INLINE
|
||||
static const Byte *FindSignature_10(const Byte *p, const Byte *limit)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (p >= limit)
|
||||
return limit;
|
||||
const Byte b = p[5];
|
||||
p += 6;
|
||||
if (b == Y0) { break; }
|
||||
if (b == Y1) { p -= 1; break; }
|
||||
if (b == Y2) { p -= 2; break; }
|
||||
if (b == Y3) { p -= 3; break; }
|
||||
if (b == Y4) { p -= 4; break; }
|
||||
if (b == Y5) { p -= 5; break; }
|
||||
}
|
||||
if (IS_SIGNATURE(p - 1))
|
||||
return p - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline bool TestStartCrc(const Byte *p)
|
||||
{
|
||||
CHECK_SIGNATURE
|
||||
return CrcCalc(p + 12, 20) == Get32(p + 8);
|
||||
}
|
||||
|
||||
#ifdef FORMAT_7Z_RECOVERY
|
||||
static inline bool TestSignature2(const Byte *p)
|
||||
{
|
||||
CHECK_SIGNATURE;
|
||||
if (CrcCalc(p + 12, 20) == Get32(p + 8))
|
||||
if (!IS_SIGNATURE(p))
|
||||
return false;
|
||||
#ifdef FORMAT_7Z_RECOVERY
|
||||
if (TestStartCrc(p))
|
||||
return true;
|
||||
for (unsigned i = 8; i < kHeaderSize; i++)
|
||||
if (p[i] != 0)
|
||||
return false;
|
||||
return (p[6] != 0 || p[7] != 0);
|
||||
#else
|
||||
return TestStartCrc(p);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
#define TestSignature2(p) TestSignature(p)
|
||||
#endif
|
||||
|
||||
|
||||
HRESULT CInArchive::FindAndReadSignature(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
|
||||
{
|
||||
RINOK(ReadStream_FALSE(stream, _header, kHeaderSize));
|
||||
RINOK(ReadStream_FALSE(stream, _header, kHeaderSize))
|
||||
|
||||
if (TestSignature2(_header))
|
||||
return S_OK;
|
||||
if (searchHeaderSizeLimit && *searchHeaderSizeLimit == 0)
|
||||
return S_FALSE;
|
||||
|
||||
const UInt32 kBufSize = 1 << 15;
|
||||
CByteArr buf(kBufSize);
|
||||
const UInt32 kBufSize = (1 << 15) + kHeaderSize; // must be > (kHeaderSize * 2)
|
||||
CAlignedBuffer1 buf(kBufSize);
|
||||
memcpy(buf, _header, kHeaderSize);
|
||||
UInt64 offset = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
UInt32 readSize = kBufSize - kHeaderSize;
|
||||
UInt32 readSize =
|
||||
(offset == 0) ?
|
||||
kBufSize - kHeaderSize - kHeaderSize :
|
||||
kBufSize - kHeaderSize;
|
||||
if (searchHeaderSizeLimit)
|
||||
{
|
||||
UInt64 rem = *searchHeaderSizeLimit - offset;
|
||||
const UInt64 rem = *searchHeaderSizeLimit - offset;
|
||||
if (readSize > rem)
|
||||
readSize = (UInt32)rem;
|
||||
if (readSize == 0)
|
||||
@@ -313,29 +364,28 @@ HRESULT CInArchive::FindAndReadSignature(IInStream *stream, const UInt64 *search
|
||||
}
|
||||
|
||||
UInt32 processed = 0;
|
||||
RINOK(stream->Read(buf + kHeaderSize, readSize, &processed));
|
||||
RINOK(stream->Read(buf + kHeaderSize, readSize, &processed))
|
||||
if (processed == 0)
|
||||
return S_FALSE;
|
||||
|
||||
/* &buf[0] was already tested for signature before.
|
||||
So first search here will be for &buf[1] */
|
||||
|
||||
for (UInt32 pos = 0;;)
|
||||
{
|
||||
const Byte *p = buf + pos + 1;
|
||||
const Byte *lim = buf + processed;
|
||||
for (; p <= lim; p += 4)
|
||||
{
|
||||
if (p[0] == '7') break;
|
||||
if (p[1] == '7') { p += 1; break; }
|
||||
if (p[2] == '7') { p += 2; break; }
|
||||
if (p[3] == '7') { p += 3; break; }
|
||||
};
|
||||
if (p > lim)
|
||||
const Byte *lim = buf + processed + 1;
|
||||
/* we have (kHeaderSize - 1 = 31) filled bytes starting from (lim),
|
||||
and it's safe to access just 10 bytes in that reserved area */
|
||||
p = FindSignature_10(p, lim);
|
||||
if (p >= lim)
|
||||
break;
|
||||
pos = (UInt32)(p - buf);
|
||||
if (TestSignature(p))
|
||||
if (TestStartCrc(p))
|
||||
{
|
||||
memcpy(_header, p, kHeaderSize);
|
||||
_arhiveBeginStreamPosition += offset + pos;
|
||||
return stream->Seek((Int64)(_arhiveBeginStreamPosition + kHeaderSize), STREAM_SEEK_SET, NULL);
|
||||
return InStream_SeekSet(stream, _arhiveBeginStreamPosition + kHeaderSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,10 +399,8 @@ HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
|
||||
{
|
||||
HeadersSize = 0;
|
||||
Close();
|
||||
RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_arhiveBeginStreamPosition))
|
||||
RINOK(stream->Seek(0, STREAM_SEEK_END, &_fileEndPosition))
|
||||
RINOK(stream->Seek((Int64)_arhiveBeginStreamPosition, STREAM_SEEK_SET, NULL))
|
||||
RINOK(FindAndReadSignature(stream, searchHeaderSizeLimit));
|
||||
RINOK(InStream_GetPos_GetSize(stream, _arhiveBeginStreamPosition, _fileEndPosition))
|
||||
RINOK(FindAndReadSignature(stream, searchHeaderSizeLimit))
|
||||
_stream = stream;
|
||||
return S_OK;
|
||||
}
|
||||
@@ -378,9 +426,9 @@ void CInArchive::ReadArchiveProperties(CInArchiveInfo & /* archiveInfo */)
|
||||
|
||||
void CInByte2::ParseFolder(CFolder &folder)
|
||||
{
|
||||
UInt32 numCoders = ReadNum();
|
||||
const UInt32 numCoders = ReadNum();
|
||||
|
||||
if (numCoders == 0)
|
||||
if (numCoders == 0 || numCoders > k_Scan_NumCoders_MAX)
|
||||
ThrowUnsupported();
|
||||
|
||||
folder.Coders.SetSize(numCoders);
|
||||
@@ -391,10 +439,10 @@ void CInByte2::ParseFolder(CFolder &folder)
|
||||
{
|
||||
CCoderInfo &coder = folder.Coders[i];
|
||||
{
|
||||
Byte mainByte = ReadByte();
|
||||
const Byte mainByte = ReadByte();
|
||||
if ((mainByte & 0xC0) != 0)
|
||||
ThrowUnsupported();
|
||||
unsigned idSize = (mainByte & 0xF);
|
||||
const unsigned idSize = (mainByte & 0xF);
|
||||
if (idSize > 8 || idSize > GetRem())
|
||||
ThrowUnsupported();
|
||||
const Byte *longID = GetPtr();
|
||||
@@ -407,7 +455,9 @@ void CInByte2::ParseFolder(CFolder &folder)
|
||||
if ((mainByte & 0x10) != 0)
|
||||
{
|
||||
coder.NumStreams = ReadNum();
|
||||
// if (coder.NumStreams > k_Scan_NumCodersStreams_in_Folder_MAX) ThrowUnsupported();
|
||||
/* numOutStreams = */ ReadNum();
|
||||
// if (ReadNum() != 1) // numOutStreams ThrowUnsupported();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -416,7 +466,7 @@ void CInByte2::ParseFolder(CFolder &folder)
|
||||
|
||||
if ((mainByte & 0x20) != 0)
|
||||
{
|
||||
CNum propsSize = ReadNum();
|
||||
const CNum propsSize = ReadNum();
|
||||
coder.Props.Alloc((size_t)propsSize);
|
||||
ReadBytes((Byte *)coder.Props, (size_t)propsSize);
|
||||
}
|
||||
@@ -426,7 +476,7 @@ void CInByte2::ParseFolder(CFolder &folder)
|
||||
numInStreams += coder.NumStreams;
|
||||
}
|
||||
|
||||
UInt32 numBonds = numCoders - 1;
|
||||
const UInt32 numBonds = numCoders - 1;
|
||||
folder.Bonds.SetSize(numBonds);
|
||||
for (i = 0; i < numBonds; i++)
|
||||
{
|
||||
@@ -437,7 +487,7 @@ void CInByte2::ParseFolder(CFolder &folder)
|
||||
|
||||
if (numInStreams < numBonds)
|
||||
ThrowUnsupported();
|
||||
UInt32 numPackStreams = numInStreams - numBonds;
|
||||
const UInt32 numPackStreams = numInStreams - numBonds;
|
||||
folder.PackStreams.SetSize(numPackStreams);
|
||||
|
||||
if (numPackStreams == 1)
|
||||
@@ -458,7 +508,7 @@ void CInByte2::ParseFolder(CFolder &folder)
|
||||
|
||||
void CFolders::ParseFolderInfo(unsigned folderIndex, CFolder &folder) const
|
||||
{
|
||||
size_t startPos = FoCodersDataOffset[folderIndex];
|
||||
const size_t startPos = FoCodersDataOffset[folderIndex];
|
||||
CInByte2 inByte;
|
||||
inByte.Init(CodersData + startPos, FoCodersDataOffset[folderIndex + 1] - startPos);
|
||||
inByte.ParseFolder(folder);
|
||||
@@ -473,8 +523,8 @@ void CDatabase::GetPath(unsigned index, UString &path) const
|
||||
if (!NameOffsets || !NamesBuf)
|
||||
return;
|
||||
|
||||
size_t offset = NameOffsets[index];
|
||||
size_t size = NameOffsets[index + 1] - offset;
|
||||
const size_t offset = NameOffsets[index];
|
||||
const size_t size = NameOffsets[index + 1] - offset;
|
||||
|
||||
if (size >= (1 << 28))
|
||||
return;
|
||||
@@ -507,8 +557,8 @@ HRESULT CDatabase::GetPath_Prop(unsigned index, PROPVARIANT *path) const throw()
|
||||
if (!NameOffsets || !NamesBuf)
|
||||
return S_OK;
|
||||
|
||||
size_t offset = NameOffsets[index];
|
||||
size_t size = NameOffsets[index + 1] - offset;
|
||||
const size_t offset = NameOffsets[index];
|
||||
const size_t size = NameOffsets[index + 1] - offset;
|
||||
|
||||
if (size >= (1 << 14))
|
||||
return S_OK;
|
||||
@@ -530,7 +580,7 @@ HRESULT CDatabase::GetPath_Prop(unsigned index, PROPVARIANT *path) const throw()
|
||||
#else
|
||||
*/
|
||||
|
||||
RINOK(PropVarEm_Alloc_Bstr(path, (unsigned)size - 1));
|
||||
RINOK(PropVarEm_Alloc_Bstr(path, (unsigned)size - 1))
|
||||
wchar_t *s = path->bstrVal;
|
||||
const Byte *p = ((const Byte *)NamesBuf + offset * 2);
|
||||
// Utf16LE__To_WCHARs_Sep(p, size, s);
|
||||
@@ -601,7 +651,7 @@ void CInArchive::WaitId(UInt64 id)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
UInt64 type = ReadID();
|
||||
const UInt64 type = ReadID();
|
||||
if (type == id)
|
||||
return;
|
||||
if (type == NID::kEnd)
|
||||
@@ -613,7 +663,7 @@ void CInArchive::WaitId(UInt64 id)
|
||||
|
||||
void CInArchive::Read_UInt32_Vector(CUInt32DefVector &v)
|
||||
{
|
||||
unsigned numItems = v.Defs.Size();
|
||||
const unsigned numItems = v.Defs.Size();
|
||||
v.Vals.ClearAndSetSize(numItems);
|
||||
UInt32 *p = &v.Vals[0];
|
||||
const bool *defs = &v.Defs[0];
|
||||
@@ -634,12 +684,9 @@ void CInArchive::ReadHashDigests(unsigned numItems, CUInt32DefVector &crcs)
|
||||
}
|
||||
|
||||
|
||||
#define k_Scan_NumCoders_MAX 64
|
||||
#define k_Scan_NumCodersStreams_in_Folder_MAX 64
|
||||
|
||||
void CInArchive::ReadPackInfo(CFolders &f)
|
||||
{
|
||||
CNum numPackStreams = ReadNum();
|
||||
const CNum numPackStreams = ReadNum();
|
||||
|
||||
WaitId(NID::kSize);
|
||||
f.PackPositions.Alloc(numPackStreams + 1);
|
||||
@@ -648,7 +695,7 @@ void CInArchive::ReadPackInfo(CFolders &f)
|
||||
for (CNum i = 0; i < numPackStreams; i++)
|
||||
{
|
||||
f.PackPositions[i] = sum;
|
||||
UInt64 packSize = ReadNumber();
|
||||
const UInt64 packSize = ReadNumber();
|
||||
sum += packSize;
|
||||
if (sum < packSize)
|
||||
ThrowIncorrect();
|
||||
@@ -676,7 +723,7 @@ void CInArchive::ReadUnpackInfo(
|
||||
CFolders &folders)
|
||||
{
|
||||
WaitId(NID::kFolder);
|
||||
CNum numFolders = ReadNum();
|
||||
const CNum numFolders = ReadNum();
|
||||
|
||||
CNum numCodersOutStreams = 0;
|
||||
{
|
||||
@@ -704,18 +751,18 @@ void CInArchive::ReadUnpackInfo(
|
||||
folders.FoCodersDataOffset[fo] = (size_t)(_inByteBack->GetPtr() - startBufPtr);
|
||||
|
||||
CNum numInStreams = 0;
|
||||
CNum numCoders = inByte->ReadNum();
|
||||
const CNum numCoders = inByte->ReadNum();
|
||||
|
||||
if (numCoders == 0 || numCoders > k_Scan_NumCoders_MAX)
|
||||
ThrowUnsupported();
|
||||
|
||||
for (CNum ci = 0; ci < numCoders; ci++)
|
||||
{
|
||||
Byte mainByte = inByte->ReadByte();
|
||||
const Byte mainByte = inByte->ReadByte();
|
||||
if ((mainByte & 0xC0) != 0)
|
||||
ThrowUnsupported();
|
||||
|
||||
unsigned idSize = (mainByte & 0xF);
|
||||
const unsigned idSize = (mainByte & 0xF);
|
||||
if (idSize > 8)
|
||||
ThrowUnsupported();
|
||||
if (idSize > inByte->GetRem())
|
||||
@@ -744,18 +791,18 @@ void CInArchive::ReadUnpackInfo(
|
||||
|
||||
if ((mainByte & 0x20) != 0)
|
||||
{
|
||||
CNum propsSize = inByte->ReadNum();
|
||||
const CNum propsSize = inByte->ReadNum();
|
||||
if (propsSize > inByte->GetRem())
|
||||
ThrowEndOfData();
|
||||
if (id == k_LZMA2 && propsSize == 1)
|
||||
{
|
||||
Byte v = *_inByteBack->GetPtr();
|
||||
const Byte v = *_inByteBack->GetPtr();
|
||||
if (folders.ParsedMethods.Lzma2Prop < v)
|
||||
folders.ParsedMethods.Lzma2Prop = v;
|
||||
}
|
||||
else if (id == k_LZMA && propsSize == 5)
|
||||
{
|
||||
UInt32 dicSize = GetUi32(_inByteBack->GetPtr() + 1);
|
||||
const UInt32 dicSize = GetUi32(_inByteBack->GetPtr() + 1);
|
||||
if (folders.ParsedMethods.LzmaDic < dicSize)
|
||||
folders.ParsedMethods.LzmaDic = dicSize;
|
||||
}
|
||||
@@ -771,7 +818,7 @@ void CInArchive::ReadUnpackInfo(
|
||||
else
|
||||
{
|
||||
UInt32 i;
|
||||
CNum numBonds = numCoders - 1;
|
||||
const CNum numBonds = numCoders - 1;
|
||||
if (numInStreams < numBonds)
|
||||
ThrowUnsupported();
|
||||
|
||||
@@ -796,7 +843,7 @@ void CInArchive::ReadUnpackInfo(
|
||||
if (numPackStreams != 1)
|
||||
for (i = 0; i < numPackStreams; i++)
|
||||
{
|
||||
CNum index = inByte->ReadNum(); // PackStreams
|
||||
const CNum index = inByte->ReadNum(); // PackStreams
|
||||
if (index >= numInStreams || StreamUsed[index])
|
||||
ThrowUnsupported();
|
||||
StreamUsed[index] = true;
|
||||
@@ -838,7 +885,7 @@ void CInArchive::ReadUnpackInfo(
|
||||
|
||||
for (;;)
|
||||
{
|
||||
UInt64 type = ReadID();
|
||||
const UInt64 type = ReadID();
|
||||
if (type == NID::kEnd)
|
||||
return;
|
||||
if (type == NID::kCRC)
|
||||
@@ -882,19 +929,19 @@ void CInArchive::ReadSubStreamsInfo(
|
||||
{
|
||||
// v3.13 incorrectly worked with empty folders
|
||||
// v4.07: we check that folder is empty
|
||||
CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
||||
const CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
||||
if (numSubstreams == 0)
|
||||
continue;
|
||||
UInt64 sum = 0;
|
||||
for (CNum j = 1; j < numSubstreams; j++)
|
||||
{
|
||||
UInt64 size = ReadNumber();
|
||||
const UInt64 size = ReadNumber();
|
||||
unpackSizes.Add(size);
|
||||
sum += size;
|
||||
if (sum < size)
|
||||
ThrowIncorrect();
|
||||
}
|
||||
UInt64 folderUnpackSize = folders.GetFolderUnpackSize(i);
|
||||
const UInt64 folderUnpackSize = folders.GetFolderUnpackSize(i);
|
||||
if (folderUnpackSize < sum)
|
||||
ThrowIncorrect();
|
||||
unpackSizes.Add(folderUnpackSize - sum);
|
||||
@@ -907,7 +954,7 @@ void CInArchive::ReadSubStreamsInfo(
|
||||
{
|
||||
/* v9.26 - v9.29 incorrectly worked:
|
||||
if (folders.NumUnpackStreamsVector[i] == 0), it threw error */
|
||||
CNum val = folders.NumUnpackStreamsVector[i];
|
||||
const CNum val = folders.NumUnpackStreamsVector[i];
|
||||
if (val > 1)
|
||||
ThrowIncorrect();
|
||||
if (val == 1)
|
||||
@@ -918,7 +965,7 @@ void CInArchive::ReadSubStreamsInfo(
|
||||
unsigned numDigests = 0;
|
||||
for (i = 0; i < folders.NumFolders; i++)
|
||||
{
|
||||
CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
||||
const CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
||||
if (numSubstreams != 1 || !folders.FolderCRCs.ValidAndDefined(i))
|
||||
numDigests += numSubstreams;
|
||||
}
|
||||
@@ -941,7 +988,7 @@ void CInArchive::ReadSubStreamsInfo(
|
||||
|
||||
for (i = 0; i < folders.NumFolders; i++)
|
||||
{
|
||||
CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
||||
const CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
||||
if (numSubstreams == 1 && folders.FolderCRCs.ValidAndDefined(i))
|
||||
{
|
||||
digests.Defs[k] = true;
|
||||
@@ -973,7 +1020,7 @@ void CInArchive::ReadSubStreamsInfo(
|
||||
unsigned k = 0;
|
||||
for (i = 0; i < folders.NumFolders; i++)
|
||||
{
|
||||
CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
||||
const CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
||||
if (numSubstreams == 1 && folders.FolderCRCs.ValidAndDefined(i))
|
||||
{
|
||||
digests.Defs[k] = true;
|
||||
@@ -1069,7 +1116,7 @@ void CInArchive::ReadBoolVector(unsigned numItems, CBoolVector &v)
|
||||
|
||||
void CInArchive::ReadBoolVector2(unsigned numItems, CBoolVector &v)
|
||||
{
|
||||
Byte allAreDefined = ReadByte();
|
||||
const Byte allAreDefined = ReadByte();
|
||||
if (allAreDefined == 0)
|
||||
{
|
||||
ReadBoolVector(numItems, v);
|
||||
@@ -1106,7 +1153,7 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 baseOffset,
|
||||
UInt64 &dataOffset, CObjectVector<CByteBuffer> &dataVector
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
)
|
||||
{
|
||||
CFolders folders;
|
||||
@@ -1148,15 +1195,15 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
|
||||
NULL // **inStreamMainRes
|
||||
, dataAfterEnd_Error
|
||||
|
||||
_7Z_DECODER_CRYPRO_VARS
|
||||
#if !defined(_7ZIP_ST)
|
||||
Z7_7Z_DECODER_CRYPRO_VARS
|
||||
#if !defined(Z7_ST)
|
||||
, false // mtMode
|
||||
, 1 // numThreads
|
||||
, 0 // memUsage
|
||||
#endif
|
||||
);
|
||||
|
||||
RINOK(result);
|
||||
RINOK(result)
|
||||
|
||||
if (dataAfterEnd_Error)
|
||||
ThereIsHeaderError = true;
|
||||
@@ -1178,7 +1225,7 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
|
||||
HRESULT CInArchive::ReadHeader(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CDbEx &db
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
)
|
||||
{
|
||||
UInt64 type = ReadID();
|
||||
@@ -1193,14 +1240,14 @@ HRESULT CInArchive::ReadHeader(
|
||||
|
||||
if (type == NID::kAdditionalStreamsInfo)
|
||||
{
|
||||
HRESULT result = ReadAndDecodePackedStreams(
|
||||
const HRESULT result = ReadAndDecodePackedStreams(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
db.ArcInfo.StartPositionAfterHeader,
|
||||
db.ArcInfo.DataStartPosition2,
|
||||
dataVector
|
||||
_7Z_DECODER_CRYPRO_VARS
|
||||
Z7_7Z_DECODER_CRYPRO_VARS
|
||||
);
|
||||
RINOK(result);
|
||||
RINOK(result)
|
||||
db.ArcInfo.DataStartPosition2 += db.ArcInfo.StartPositionAfterHeader;
|
||||
type = ReadID();
|
||||
}
|
||||
@@ -1240,7 +1287,7 @@ HRESULT CInArchive::ReadHeader(
|
||||
const UInt64 type2 = ReadID();
|
||||
if (type2 == NID::kEnd)
|
||||
break;
|
||||
UInt64 size = ReadNumber();
|
||||
const UInt64 size = ReadNumber();
|
||||
if (size > _inByteBack->GetRem())
|
||||
ThrowIncorrect();
|
||||
CStreamSwitch switchProp;
|
||||
@@ -1255,7 +1302,7 @@ HRESULT CInArchive::ReadHeader(
|
||||
{
|
||||
CStreamSwitch streamSwitch;
|
||||
streamSwitch.Set(this, &dataVector);
|
||||
size_t rem = _inByteBack->GetRem();
|
||||
const size_t rem = _inByteBack->GetRem();
|
||||
db.NamesBuf.Alloc(rem);
|
||||
ReadBytes(db.NamesBuf, rem);
|
||||
db.NameOffsets.Alloc(numFiles + 1);
|
||||
@@ -1471,7 +1518,7 @@ void CDbEx::FillLinks()
|
||||
|
||||
for (i = 0; i < Files.Size(); i++)
|
||||
{
|
||||
bool emptyStream = !Files[i].HasStream;
|
||||
const bool emptyStream = !Files[i].HasStream;
|
||||
if (indexInFolder == 0)
|
||||
{
|
||||
if (emptyStream)
|
||||
@@ -1528,7 +1575,7 @@ void CDbEx::FillLinks()
|
||||
HRESULT CInArchive::ReadDatabase2(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CDbEx &db
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
)
|
||||
{
|
||||
db.Clear();
|
||||
@@ -1548,22 +1595,22 @@ HRESULT CInArchive::ReadDatabase2(
|
||||
UInt32 nextHeaderCRC = Get32(_header + 28);
|
||||
|
||||
#ifdef FORMAT_7Z_RECOVERY
|
||||
UInt32 crcFromArc = Get32(_header + 8);
|
||||
const UInt32 crcFromArc = Get32(_header + 8);
|
||||
if (crcFromArc == 0 && nextHeaderOffset == 0 && nextHeaderSize == 0 && nextHeaderCRC == 0)
|
||||
{
|
||||
UInt64 cur, fileSize;
|
||||
RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &cur));
|
||||
RINOK(InStream_GetPos(_stream, cur))
|
||||
const unsigned kCheckSize = 512;
|
||||
Byte buf[kCheckSize];
|
||||
RINOK(_stream->Seek(0, STREAM_SEEK_END, &fileSize));
|
||||
RINOK(InStream_GetSize_SeekToEnd(_stream, fileSize))
|
||||
const UInt64 rem = fileSize - cur;
|
||||
unsigned checkSize = kCheckSize;
|
||||
if (rem < kCheckSize)
|
||||
checkSize = (unsigned)(rem);
|
||||
if (checkSize < 3)
|
||||
return S_FALSE;
|
||||
RINOK(_stream->Seek((Int64)(fileSize - checkSize), STREAM_SEEK_SET, NULL));
|
||||
RINOK(ReadStream_FALSE(_stream, buf, (size_t)checkSize));
|
||||
RINOK(InStream_SeekSet(_stream, fileSize - checkSize))
|
||||
RINOK(ReadStream_FALSE(_stream, buf, (size_t)checkSize))
|
||||
|
||||
if (buf[checkSize - 1] != 0)
|
||||
return S_FALSE;
|
||||
@@ -1580,7 +1627,7 @@ HRESULT CInArchive::ReadDatabase2(
|
||||
nextHeaderSize = checkSize - i;
|
||||
nextHeaderOffset = rem - nextHeaderSize;
|
||||
nextHeaderCRC = CrcCalc(buf + i, (size_t)nextHeaderSize);
|
||||
RINOK(_stream->Seek((Int64)cur, STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(_stream, cur))
|
||||
db.StartHeaderWasRecovered = true;
|
||||
}
|
||||
else
|
||||
@@ -1622,14 +1669,14 @@ HRESULT CInArchive::ReadDatabase2(
|
||||
db.UnexpectedEnd = true;
|
||||
return S_FALSE;
|
||||
}
|
||||
RINOK(_stream->Seek((Int64)nextHeaderOffset, STREAM_SEEK_CUR, NULL));
|
||||
RINOK(_stream->Seek((Int64)nextHeaderOffset, STREAM_SEEK_CUR, NULL))
|
||||
|
||||
size_t nextHeaderSize_t = (size_t)nextHeaderSize;
|
||||
const size_t nextHeaderSize_t = (size_t)nextHeaderSize;
|
||||
if (nextHeaderSize_t != nextHeaderSize)
|
||||
return E_OUTOFMEMORY;
|
||||
CByteBuffer buffer2(nextHeaderSize_t);
|
||||
|
||||
RINOK(ReadStream_FALSE(_stream, buffer2, nextHeaderSize_t));
|
||||
RINOK(ReadStream_FALSE(_stream, buffer2, nextHeaderSize_t))
|
||||
|
||||
if (CrcCalc(buffer2, nextHeaderSize_t) != nextHeaderCRC)
|
||||
ThrowIncorrect();
|
||||
@@ -1642,19 +1689,19 @@ HRESULT CInArchive::ReadDatabase2(
|
||||
|
||||
CObjectVector<CByteBuffer> dataVector;
|
||||
|
||||
UInt64 type = ReadID();
|
||||
const UInt64 type = ReadID();
|
||||
if (type != NID::kHeader)
|
||||
{
|
||||
if (type != NID::kEncodedHeader)
|
||||
ThrowIncorrect();
|
||||
HRESULT result = ReadAndDecodePackedStreams(
|
||||
const HRESULT result = ReadAndDecodePackedStreams(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
db.ArcInfo.StartPositionAfterHeader,
|
||||
db.ArcInfo.DataStartPosition2,
|
||||
dataVector
|
||||
_7Z_DECODER_CRYPRO_VARS
|
||||
Z7_7Z_DECODER_CRYPRO_VARS
|
||||
);
|
||||
RINOK(result);
|
||||
RINOK(result)
|
||||
if (dataVector.Size() == 0)
|
||||
return S_OK;
|
||||
if (dataVector.Size() > 1)
|
||||
@@ -1672,7 +1719,7 @@ HRESULT CInArchive::ReadDatabase2(
|
||||
return ReadHeader(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
db
|
||||
_7Z_DECODER_CRYPRO_VARS
|
||||
Z7_7Z_DECODER_CRYPRO_VARS
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1680,14 +1727,14 @@ HRESULT CInArchive::ReadDatabase2(
|
||||
HRESULT CInArchive::ReadDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CDbEx &db
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
HRESULT res = ReadDatabase2(
|
||||
const HRESULT res = ReadDatabase2(
|
||||
EXTERNAL_CODECS_LOC_VARS db
|
||||
_7Z_DECODER_CRYPRO_VARS
|
||||
Z7_7Z_DECODER_CRYPRO_VARS
|
||||
);
|
||||
if (ThereIsHeaderError)
|
||||
db.ThereIsHeaderError = true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 7zIn.h
|
||||
|
||||
#ifndef __7Z_IN_H
|
||||
#define __7Z_IN_H
|
||||
#ifndef ZIP7_INC_7Z_IN_H
|
||||
#define ZIP7_INC_7Z_IN_H
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
@@ -22,12 +22,12 @@ namespace N7z {
|
||||
We don't need to init isEncrypted and passwordIsDefined
|
||||
We must upgrade them only */
|
||||
|
||||
#ifdef _NO_CRYPTO
|
||||
#define _7Z_DECODER_CRYPRO_VARS_DECL
|
||||
#define _7Z_DECODER_CRYPRO_VARS
|
||||
#ifdef Z7_NO_CRYPTO
|
||||
#define Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
#define Z7_7Z_DECODER_CRYPRO_VARS
|
||||
#else
|
||||
#define _7Z_DECODER_CRYPRO_VARS_DECL , ICryptoGetTextPassword *getTextPassword, bool &isEncrypted, bool &passwordIsDefined, UString &password
|
||||
#define _7Z_DECODER_CRYPRO_VARS , getTextPassword, isEncrypted, passwordIsDefined, password
|
||||
#define Z7_7Z_DECODER_CRYPRO_VARS_DECL , ICryptoGetTextPassword *getTextPassword, bool &isEncrypted, bool &passwordIsDefined, UString &password
|
||||
#define Z7_7Z_DECODER_CRYPRO_VARS , getTextPassword, isEncrypted, passwordIsDefined, password
|
||||
#endif
|
||||
|
||||
struct CParsedMethods
|
||||
@@ -418,17 +418,17 @@ class CInArchive
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 baseOffset, UInt64 &dataOffset,
|
||||
CObjectVector<CByteBuffer> &dataVector
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
);
|
||||
HRESULT ReadHeader(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CDbEx &db
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
);
|
||||
HRESULT ReadDatabase2(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CDbEx &db
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
);
|
||||
public:
|
||||
CInArchive(bool useMixerMT):
|
||||
@@ -442,7 +442,7 @@ public:
|
||||
HRESULT ReadDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CDbEx &db
|
||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
Z7_7Z_DECODER_CRYPRO_VARS_DECL
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 7zItem.h
|
||||
|
||||
#ifndef __7Z_ITEM_H
|
||||
#define __7Z_ITEM_H
|
||||
#ifndef ZIP7_INC_7Z_ITEM_H
|
||||
#define ZIP7_INC_7Z_ITEM_H
|
||||
|
||||
#include "../../../Common/MyBuffer.h"
|
||||
#include "../../../Common/MyString.h"
|
||||
@@ -36,7 +36,7 @@ struct CBond
|
||||
|
||||
struct CFolder
|
||||
{
|
||||
CLASS_NO_COPY(CFolder)
|
||||
Z7_CLASS_NO_COPY(CFolder)
|
||||
public:
|
||||
CObjArray2<CCoderInfo> Coders;
|
||||
CObjArray2<CBond> Bonds;
|
||||
@@ -129,6 +129,11 @@ struct CUInt32DefVector
|
||||
bool CheckSize(unsigned size) const { return Defs.Size() == size || Defs.Size() == 0; }
|
||||
|
||||
void SetItem(unsigned index, bool defined, UInt32 value);
|
||||
void if_NonEmpty_FillResedue_with_false(unsigned numItems)
|
||||
{
|
||||
if (Defs.Size() != 0 && Defs.Size() < numItems)
|
||||
SetItem(numItems - 1, false, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -14,16 +14,14 @@
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
HRESULT COutArchive::WriteSignature()
|
||||
static void FillSignature(Byte *buf)
|
||||
{
|
||||
Byte buf[8];
|
||||
memcpy(buf, kSignature, kSignatureSize);
|
||||
buf[kSignatureSize] = kMajorVersion;
|
||||
buf[kSignatureSize + 1] = 4;
|
||||
return WriteDirect(buf, 8);
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
HRESULT COutArchive::WriteFinishSignature()
|
||||
{
|
||||
RINOK(WriteDirect(kFinishSignature, kSignatureSize));
|
||||
@@ -49,15 +47,16 @@ static void SetUInt64(Byte *p, UInt64 d)
|
||||
|
||||
HRESULT COutArchive::WriteStartHeader(const CStartHeader &h)
|
||||
{
|
||||
Byte buf[24];
|
||||
SetUInt64(buf + 4, h.NextHeaderOffset);
|
||||
SetUInt64(buf + 12, h.NextHeaderSize);
|
||||
SetUInt32(buf + 20, h.NextHeaderCRC);
|
||||
SetUInt32(buf, CrcCalc(buf + 4, 20));
|
||||
return WriteDirect(buf, 24);
|
||||
Byte buf[32];
|
||||
FillSignature(buf);
|
||||
SetUInt64(buf + 8 + 4, h.NextHeaderOffset);
|
||||
SetUInt64(buf + 8 + 12, h.NextHeaderSize);
|
||||
SetUInt32(buf + 8 + 20, h.NextHeaderCRC);
|
||||
SetUInt32(buf + 8, CrcCalc(buf + 8 + 4, 20));
|
||||
return WriteDirect(buf, sizeof(buf));
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
HRESULT COutArchive::WriteFinishHeader(const CFinishHeader &h)
|
||||
{
|
||||
CCRC crc;
|
||||
@@ -75,15 +74,15 @@ HRESULT COutArchive::WriteFinishHeader(const CFinishHeader &h)
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT COutArchive::Create(ISequentialOutStream *stream, bool endMarker)
|
||||
HRESULT COutArchive::Create_and_WriteStartPrefix(ISequentialOutStream *stream /* , bool endMarker */)
|
||||
{
|
||||
Close();
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
// endMarker = false;
|
||||
_endMarker = endMarker;
|
||||
#endif
|
||||
SeqStream = stream;
|
||||
if (!endMarker)
|
||||
// if (!endMarker)
|
||||
{
|
||||
SeqStream.QueryInterface(IID_IOutStream, &Stream);
|
||||
if (!Stream)
|
||||
@@ -91,8 +90,13 @@ HRESULT COutArchive::Create(ISequentialOutStream *stream, bool endMarker)
|
||||
return E_NOTIMPL;
|
||||
// endMarker = true;
|
||||
}
|
||||
RINOK(Stream->Seek(0, STREAM_SEEK_CUR, &_signatureHeaderPos))
|
||||
Byte buf[32];
|
||||
FillSignature(buf);
|
||||
memset(&buf[8], 0, 32 - 8);
|
||||
return WriteDirect(buf, sizeof(buf));
|
||||
}
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
if (endMarker)
|
||||
{
|
||||
/*
|
||||
@@ -101,17 +105,10 @@ HRESULT COutArchive::Create(ISequentialOutStream *stream, bool endMarker)
|
||||
sh.NextHeaderSize = (UInt32)(Int32)-1;
|
||||
sh.NextHeaderCRC = 0;
|
||||
WriteStartHeader(sh);
|
||||
return S_OK;
|
||||
*/
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (!Stream)
|
||||
return E_FAIL;
|
||||
RINOK(WriteSignature());
|
||||
RINOK(Stream->Seek(0, STREAM_SEEK_CUR, &_prefixHeaderPos));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void COutArchive::Close()
|
||||
@@ -120,17 +117,6 @@ void COutArchive::Close()
|
||||
Stream.Release();
|
||||
}
|
||||
|
||||
HRESULT COutArchive::SkipPrefixArchiveHeader()
|
||||
{
|
||||
#ifdef _7Z_VOL
|
||||
if (_endMarker)
|
||||
return S_OK;
|
||||
#endif
|
||||
Byte buf[24];
|
||||
memset(buf, 0, 24);
|
||||
return WriteDirect(buf, 24);
|
||||
}
|
||||
|
||||
UInt64 COutArchive::GetPos() const
|
||||
{
|
||||
if (_countMode)
|
||||
@@ -216,7 +202,7 @@ static unsigned GetBigNumberSize(UInt64 value)
|
||||
return i;
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
UInt32 COutArchive::GetVolHeadersSize(UInt64 dataSize, int nameLength, bool props)
|
||||
{
|
||||
UInt32 result = GetBigNumberSize(dataSize) * 2 + 41;
|
||||
@@ -515,14 +501,20 @@ HRESULT COutArchive::EncodeStream(
|
||||
outFolders.FolderUnpackCRCs.Defs.Add(true);
|
||||
outFolders.FolderUnpackCRCs.Vals.Add(CrcCalc(data, data.Size()));
|
||||
// outFolders.NumUnpackStreamsVector.Add(1);
|
||||
UInt64 dataSize64 = data.Size();
|
||||
UInt64 unpackSize = data.Size();
|
||||
RINOK(encoder.Encode(
|
||||
const UInt64 dataSize64 = data.Size();
|
||||
const UInt64 expectSize = data.Size();
|
||||
RINOK(encoder.Encode1(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
stream,
|
||||
// NULL,
|
||||
&dataSize64,
|
||||
folders.AddNew(), outFolders.CoderUnpackSizes, unpackSize, SeqStream, packSizes, NULL))
|
||||
&dataSize64, // inSizeForReduce
|
||||
expectSize,
|
||||
folders.AddNew(),
|
||||
// outFolders.CoderUnpackSizes, unpackSize,
|
||||
SeqStream, packSizes, NULL))
|
||||
if (!streamSpec->WasFinished())
|
||||
return E_FAIL;
|
||||
encoder.Encode_Post(dataSize64, outFolders.CoderUnpackSizes);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -833,15 +825,15 @@ HRESULT COutArchive::WriteDatabase(
|
||||
{
|
||||
headerSize = 0;
|
||||
headerOffset = 0;
|
||||
headerCRC = CrcCalc(0, 0);
|
||||
headerCRC = CrcCalc(NULL, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool encodeHeaders = false;
|
||||
if (options != 0)
|
||||
if (options)
|
||||
if (options->IsEmpty())
|
||||
options = 0;
|
||||
if (options != 0)
|
||||
options = NULL;
|
||||
if (options)
|
||||
if (options->PasswordIsDefined || headerOptions.CompressMainHeader)
|
||||
encodeHeaders = true;
|
||||
|
||||
@@ -876,7 +868,7 @@ HRESULT COutArchive::WriteDatabase(
|
||||
RINOK(EncodeStream(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
encoder, buf,
|
||||
packSizes, folders, outFolders));
|
||||
packSizes, folders, outFolders))
|
||||
|
||||
_writeToStream = true;
|
||||
|
||||
@@ -890,11 +882,11 @@ HRESULT COutArchive::WriteDatabase(
|
||||
FOR_VECTOR (i, packSizes)
|
||||
headerOffset += packSizes[i];
|
||||
}
|
||||
RINOK(_outByte.Flush());
|
||||
RINOK(_outByte.Flush())
|
||||
headerCRC = CRC_GET_DIGEST(_crc);
|
||||
headerSize = _outByte.GetProcessedSize();
|
||||
}
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
if (_endMarker)
|
||||
{
|
||||
CFinishHeader h;
|
||||
@@ -910,14 +902,16 @@ HRESULT COutArchive::WriteDatabase(
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (Stream)
|
||||
{
|
||||
CStartHeader h;
|
||||
h.NextHeaderSize = headerSize;
|
||||
h.NextHeaderCRC = headerCRC;
|
||||
h.NextHeaderOffset = headerOffset;
|
||||
RINOK(Stream->Seek((Int64)_prefixHeaderPos, STREAM_SEEK_SET, NULL));
|
||||
RINOK(Stream->Seek((Int64)_signatureHeaderPos, STREAM_SEEK_SET, NULL))
|
||||
return WriteStartHeader(h);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CUInt32DefVector::SetItem(unsigned index, bool defined, UInt32 value)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 7zOut.h
|
||||
|
||||
#ifndef __7Z_OUT_H
|
||||
#define __7Z_OUT_H
|
||||
#ifndef ZIP7_INC_7Z_OUT_H
|
||||
#define ZIP7_INC_7Z_OUT_H
|
||||
|
||||
#include "7zCompressionMode.h"
|
||||
#include "7zEncode.h"
|
||||
@@ -14,6 +14,8 @@
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
const unsigned k_StartHeadersRewriteSize = 32;
|
||||
|
||||
class CWriteBufferLoc
|
||||
{
|
||||
Byte *_data;
|
||||
@@ -240,8 +242,6 @@ struct CArchiveDatabaseOut: public COutFolders
|
||||
|
||||
class COutArchive
|
||||
{
|
||||
UInt64 _prefixHeaderPos;
|
||||
|
||||
HRESULT WriteDirect(const void *data, UInt32 size) { return WriteStream(SeqStream, data, size); }
|
||||
|
||||
UInt64 GetPos() const;
|
||||
@@ -290,44 +290,39 @@ class COutArchive
|
||||
|
||||
bool _countMode;
|
||||
bool _writeToStream;
|
||||
size_t _countSize;
|
||||
UInt32 _crc;
|
||||
COutBuffer _outByte;
|
||||
CWriteBufferLoc _outByte2;
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
bool _useAlign;
|
||||
#ifdef Z7_7Z_VOL
|
||||
bool _endMarker;
|
||||
#endif
|
||||
UInt32 _crc;
|
||||
size_t _countSize;
|
||||
CWriteBufferLoc _outByte2;
|
||||
COutBuffer _outByte;
|
||||
UInt64 _signatureHeaderPos;
|
||||
CMyComPtr<IOutStream> Stream;
|
||||
|
||||
bool _useAlign;
|
||||
|
||||
HRESULT WriteSignature();
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
HRESULT WriteFinishSignature();
|
||||
#endif
|
||||
HRESULT WriteStartHeader(const CStartHeader &h);
|
||||
#ifdef _7Z_VOL
|
||||
HRESULT WriteFinishHeader(const CFinishHeader &h);
|
||||
#endif
|
||||
CMyComPtr<IOutStream> Stream;
|
||||
HRESULT WriteStartHeader(const CStartHeader &h);
|
||||
|
||||
public:
|
||||
CMyComPtr<ISequentialOutStream> SeqStream;
|
||||
|
||||
COutArchive() { _outByte.Create(1 << 16); }
|
||||
CMyComPtr<ISequentialOutStream> SeqStream;
|
||||
HRESULT Create(ISequentialOutStream *stream, bool endMarker);
|
||||
HRESULT Create_and_WriteStartPrefix(ISequentialOutStream *stream /* , bool endMarker */);
|
||||
void Close();
|
||||
HRESULT SkipPrefixArchiveHeader();
|
||||
HRESULT WriteDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const CArchiveDatabaseOut &db,
|
||||
const CCompressionMethodMode *options,
|
||||
const CHeaderOptions &headerOptions);
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
static UInt32 GetVolHeadersSize(UInt64 dataSize, int nameLength = 0, bool props = false);
|
||||
static UInt64 GetVolPureSize(UInt64 volSize, int nameLength = 0, bool props = false);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -2,56 +2,63 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "7zProperties.h"
|
||||
#include "7zHeader.h"
|
||||
#include "7zHandler.h"
|
||||
|
||||
// #define _MULTI_PACK
|
||||
#include "7zProperties.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
struct CPropMap
|
||||
{
|
||||
UInt32 FilePropID;
|
||||
CStatProp StatProp;
|
||||
Byte FilePropID;
|
||||
// CStatProp StatProp;
|
||||
VARTYPE vt;
|
||||
UInt32 StatPropID;
|
||||
};
|
||||
|
||||
// #define STAT_PROP(name, id, vt) { name, id, vt }
|
||||
#define STAT_PROP(name, id, vt) vt, id
|
||||
|
||||
#define STAT_PROP2(id, vt) STAT_PROP(NULL, id, vt)
|
||||
|
||||
#define k_7z_id_Encrypted 97
|
||||
#define k_7z_id_Method 98
|
||||
#define k_7z_id_Block 99
|
||||
|
||||
static const CPropMap kPropMap[] =
|
||||
{
|
||||
{ NID::kName, { NULL, kpidPath, VT_BSTR } },
|
||||
{ NID::kSize, { NULL, kpidSize, VT_UI8 } },
|
||||
{ NID::kPackInfo, { NULL, kpidPackSize, VT_UI8 } },
|
||||
{ NID::kName, STAT_PROP2(kpidPath, VT_BSTR) },
|
||||
{ NID::kSize, STAT_PROP2(kpidSize, VT_UI8) },
|
||||
{ NID::kPackInfo, STAT_PROP2(kpidPackSize, VT_UI8) },
|
||||
|
||||
#ifdef _MULTI_PACK
|
||||
{ 100, { "Pack0", kpidPackedSize0, VT_UI8 } },
|
||||
{ 101, { "Pack1", kpidPackedSize1, VT_UI8 } },
|
||||
{ 102, { "Pack2", kpidPackedSize2, VT_UI8 } },
|
||||
{ 103, { "Pack3", kpidPackedSize3, VT_UI8 } },
|
||||
{ 104, { "Pack4", kpidPackedSize4, VT_UI8 } },
|
||||
#ifdef Z7_7Z_SHOW_PACK_STREAMS_SIZES
|
||||
#define k_7z_id_PackedSize0 100
|
||||
{ k_7z_id_PackedSize0 + 0, STAT_PROP("Pack0", kpidPackedSize0, VT_UI8) },
|
||||
{ k_7z_id_PackedSize0 + 1, STAT_PROP("Pack1", kpidPackedSize1, VT_UI8) },
|
||||
{ k_7z_id_PackedSize0 + 2, STAT_PROP("Pack2", kpidPackedSize2, VT_UI8) },
|
||||
{ k_7z_id_PackedSize0 + 3, STAT_PROP("Pack3", kpidPackedSize3, VT_UI8) },
|
||||
{ k_7z_id_PackedSize0 + 4, STAT_PROP("Pack4", kpidPackedSize4, VT_UI8) },
|
||||
#endif
|
||||
|
||||
{ NID::kCTime, { NULL, kpidCTime, VT_FILETIME } },
|
||||
{ NID::kMTime, { NULL, kpidMTime, VT_FILETIME } },
|
||||
{ NID::kATime, { NULL, kpidATime, VT_FILETIME } },
|
||||
{ NID::kWinAttrib, { NULL, kpidAttrib, VT_UI4 } },
|
||||
{ NID::kStartPos, { NULL, kpidPosition, VT_UI8 } },
|
||||
{ NID::kCTime, STAT_PROP2(kpidCTime, VT_FILETIME) },
|
||||
{ NID::kMTime, STAT_PROP2(kpidMTime, VT_FILETIME) },
|
||||
{ NID::kATime, STAT_PROP2(kpidATime, VT_FILETIME) },
|
||||
{ NID::kWinAttrib, STAT_PROP2(kpidAttrib, VT_UI4) },
|
||||
{ NID::kStartPos, STAT_PROP2(kpidPosition, VT_UI8) },
|
||||
|
||||
{ NID::kCRC, { NULL, kpidCRC, VT_UI4 } },
|
||||
|
||||
// { NID::kIsAux, { NULL, kpidIsAux, VT_BOOL } },
|
||||
{ NID::kAnti, { NULL, kpidIsAnti, VT_BOOL } }
|
||||
{ NID::kCRC, STAT_PROP2(kpidCRC, VT_UI4) },
|
||||
// { NID::kIsAux, STAT_PROP2(kpidIsAux, VT_BOOL) },
|
||||
{ NID::kAnti, STAT_PROP2(kpidIsAnti, VT_BOOL) }
|
||||
|
||||
#ifndef _SFX
|
||||
,
|
||||
{ 97, { NULL, kpidEncrypted, VT_BOOL } },
|
||||
{ 98, { NULL, kpidMethod, VT_BSTR } },
|
||||
{ 99, { NULL, kpidBlock, VT_UI4 } }
|
||||
#ifndef Z7_SFX
|
||||
, { k_7z_id_Encrypted, STAT_PROP2(kpidEncrypted, VT_BOOL) }
|
||||
, { k_7z_id_Method, STAT_PROP2(kpidMethod, VT_BSTR) }
|
||||
, { k_7z_id_Block, STAT_PROP2(kpidBlock, VT_UI4) }
|
||||
#endif
|
||||
};
|
||||
|
||||
static void CopyOneItem(CRecordVector<UInt64> &src,
|
||||
CRecordVector<UInt64> &dest, UInt32 item)
|
||||
CRecordVector<UInt64> &dest, const UInt32 item)
|
||||
{
|
||||
FOR_VECTOR (i, src)
|
||||
if (src[i] == item)
|
||||
@@ -62,7 +69,7 @@ static void CopyOneItem(CRecordVector<UInt64> &src,
|
||||
}
|
||||
}
|
||||
|
||||
static void RemoveOneItem(CRecordVector<UInt64> &src, UInt32 item)
|
||||
static void RemoveOneItem(CRecordVector<UInt64> &src, const UInt32 item)
|
||||
{
|
||||
FOR_VECTOR (i, src)
|
||||
if (src[i] == item)
|
||||
@@ -72,7 +79,7 @@ static void RemoveOneItem(CRecordVector<UInt64> &src, UInt32 item)
|
||||
}
|
||||
}
|
||||
|
||||
static void InsertToHead(CRecordVector<UInt64> &dest, UInt32 item)
|
||||
static void InsertToHead(CRecordVector<UInt64> &dest, const UInt32 item)
|
||||
{
|
||||
FOR_VECTOR (i, dest)
|
||||
if (dest[i] == item)
|
||||
@@ -89,7 +96,7 @@ void CHandler::FillPopIDs()
|
||||
{
|
||||
_fileInfoPopIDs.Clear();
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
#ifdef Z7_7Z_VOL
|
||||
if (_volumes.Size() < 1)
|
||||
return;
|
||||
const CVolume &volume = _volumes.Front();
|
||||
@@ -105,34 +112,31 @@ void CHandler::FillPopIDs()
|
||||
RemoveOneItem(fileInfoPopIDs, NID::kNtSecure);
|
||||
*/
|
||||
|
||||
COPY_ONE_ITEM(kName);
|
||||
COPY_ONE_ITEM(kAnti);
|
||||
COPY_ONE_ITEM(kSize);
|
||||
COPY_ONE_ITEM(kPackInfo);
|
||||
COPY_ONE_ITEM(kCTime);
|
||||
COPY_ONE_ITEM(kMTime);
|
||||
COPY_ONE_ITEM(kATime);
|
||||
COPY_ONE_ITEM(kWinAttrib);
|
||||
COPY_ONE_ITEM(kCRC);
|
||||
COPY_ONE_ITEM(kComment);
|
||||
COPY_ONE_ITEM(kName)
|
||||
COPY_ONE_ITEM(kAnti)
|
||||
COPY_ONE_ITEM(kSize)
|
||||
COPY_ONE_ITEM(kPackInfo)
|
||||
COPY_ONE_ITEM(kCTime)
|
||||
COPY_ONE_ITEM(kMTime)
|
||||
COPY_ONE_ITEM(kATime)
|
||||
COPY_ONE_ITEM(kWinAttrib)
|
||||
COPY_ONE_ITEM(kCRC)
|
||||
COPY_ONE_ITEM(kComment)
|
||||
|
||||
_fileInfoPopIDs += fileInfoPopIDs;
|
||||
|
||||
#ifndef _SFX
|
||||
_fileInfoPopIDs.Add(97);
|
||||
_fileInfoPopIDs.Add(98);
|
||||
_fileInfoPopIDs.Add(99);
|
||||
#ifndef Z7_SFX
|
||||
_fileInfoPopIDs.Add(k_7z_id_Encrypted);
|
||||
_fileInfoPopIDs.Add(k_7z_id_Method);
|
||||
_fileInfoPopIDs.Add(k_7z_id_Block);
|
||||
#endif
|
||||
|
||||
#ifdef _MULTI_PACK
|
||||
_fileInfoPopIDs.Add(100);
|
||||
_fileInfoPopIDs.Add(101);
|
||||
_fileInfoPopIDs.Add(102);
|
||||
_fileInfoPopIDs.Add(103);
|
||||
_fileInfoPopIDs.Add(104);
|
||||
#ifdef Z7_7Z_SHOW_PACK_STREAMS_SIZES
|
||||
for (unsigned i = 0; i < 5; i++)
|
||||
_fileInfoPopIDs.Add(k_7z_id_PackedSize0 + i);
|
||||
#endif
|
||||
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
InsertToHead(_fileInfoPopIDs, NID::kMTime);
|
||||
InsertToHead(_fileInfoPopIDs, NID::kPackInfo);
|
||||
InsertToHead(_fileInfoPopIDs, NID::kSize);
|
||||
@@ -140,25 +144,29 @@ void CHandler::FillPopIDs()
|
||||
#endif
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProps)
|
||||
Z7_COM7F_IMF(CHandler::GetNumberOfProperties(UInt32 *numProps))
|
||||
{
|
||||
*numProps = _fileInfoPopIDs.Size();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
Z7_COM7F_IMF(CHandler::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType))
|
||||
{
|
||||
if (index >= _fileInfoPopIDs.Size())
|
||||
return E_INVALIDARG;
|
||||
UInt64 id = _fileInfoPopIDs[index];
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(kPropMap); i++)
|
||||
const UInt64 id = _fileInfoPopIDs[index];
|
||||
for (unsigned i = 0; i < Z7_ARRAY_SIZE(kPropMap); i++)
|
||||
{
|
||||
const CPropMap &pr = kPropMap[i];
|
||||
if (pr.FilePropID == id)
|
||||
{
|
||||
*propID = pr.StatPropID;
|
||||
*varType = pr.vt;
|
||||
/*
|
||||
const CStatProp &st = pr.StatProp;
|
||||
*propID = st.PropID;
|
||||
*varType = st.vt;
|
||||
*/
|
||||
/*
|
||||
if (st.lpwstrName)
|
||||
*name = ::SysAllocString(st.lpwstrName);
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
// 7zProperties.h
|
||||
|
||||
#ifndef __7Z_PROPERTIES_H
|
||||
#define __7Z_PROPERTIES_H
|
||||
#ifndef ZIP7_INC_7Z_PROPERTIES_H
|
||||
#define ZIP7_INC_7Z_PROPERTIES_H
|
||||
|
||||
#include "../../PropID.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
// #define Z7_7Z_SHOW_PACK_STREAMS_SIZES // for debug
|
||||
|
||||
#ifdef Z7_7Z_SHOW_PACK_STREAMS_SIZES
|
||||
enum
|
||||
{
|
||||
kpidPackedSize0 = kpidUserDefined,
|
||||
@@ -16,6 +19,7 @@ enum
|
||||
kpidPackedSize3,
|
||||
kpidPackedSize4
|
||||
};
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -22,6 +22,6 @@ REGISTER_ARC_IO_DECREMENT_SIG(
|
||||
| NArcInfoFlags::kMTime_Default
|
||||
, TIME_PREC_TO_ARC_FLAGS_MASK(NFileTimeType::kWindows)
|
||||
| TIME_PREC_TO_ARC_FLAGS_TIME_DEFAULT(NFileTimeType::kWindows)
|
||||
, NULL);
|
||||
, NULL)
|
||||
|
||||
}}
|
||||
|
||||
@@ -4,19 +4,28 @@
|
||||
|
||||
#include "7zSpecStream.h"
|
||||
|
||||
STDMETHODIMP CSequentialInStreamSizeCount2::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
/*
|
||||
Z7_COM7F_IMF(CSequentialInStreamSizeCount2::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
UInt32 realProcessedSize;
|
||||
HRESULT result = _stream->Read(data, size, &realProcessedSize);
|
||||
const HRESULT result = _stream->Read(data, size, &realProcessedSize);
|
||||
_size += realProcessedSize;
|
||||
if (processedSize)
|
||||
*processedSize = realProcessedSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP CSequentialInStreamSizeCount2::GetSubStreamSize(UInt64 subStream, UInt64 *value)
|
||||
Z7_COM7F_IMF(CSequentialInStreamSizeCount2::GetSubStreamSize(UInt64 subStream, UInt64 *value))
|
||||
{
|
||||
if (!_getSubStreamSize)
|
||||
return E_NOTIMPL;
|
||||
return _getSubStreamSize->GetSubStreamSize(subStream, value);
|
||||
}
|
||||
|
||||
Z7_COM7F_IMF(CSequentialInStreamSizeCount2::GetNextInSubStream(UInt64 *streamIndexRes, ISequentialInStream **stream))
|
||||
{
|
||||
if (!_compressGetSubStreamSize)
|
||||
return E_NOTIMPL;
|
||||
return _compressGetSubStreamSize->GetNextInSubStream(streamIndexRes, stream);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,35 +1,49 @@
|
||||
// 7zSpecStream.h
|
||||
|
||||
#ifndef __7Z_SPEC_STREAM_H
|
||||
#define __7Z_SPEC_STREAM_H
|
||||
#ifndef ZIP7_INC_7Z_SPEC_STREAM_H
|
||||
#define ZIP7_INC_7Z_SPEC_STREAM_H
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
#include "../../ICoder.h"
|
||||
|
||||
class CSequentialInStreamSizeCount2:
|
||||
/*
|
||||
#define Z7_COM_QI_ENTRY_AG_2(i, sub0, sub) else if (iid == IID_ ## i) \
|
||||
{ if (!sub) RINOK(sub0->QueryInterface(IID_ ## i, (void **)&sub)) \
|
||||
{ i *ti = this; *outObject = ti; } }
|
||||
|
||||
class CSequentialInStreamSizeCount2 Z7_final:
|
||||
public ISequentialInStream,
|
||||
public ICompressGetSubStreamSize,
|
||||
public ICompressInSubStreams,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_COM_QI_BEGIN2(ISequentialInStream)
|
||||
Z7_COM_QI_ENTRY(ICompressGetSubStreamSize)
|
||||
Z7_COM_QI_ENTRY_AG_2(ISequentialInStream, _stream, _compressGetSubStreamSize)
|
||||
Z7_COM_QI_END
|
||||
Z7_COM_ADDREF_RELEASE
|
||||
|
||||
Z7_IFACE_COM7_IMP(ISequentialInStream)
|
||||
Z7_IFACE_COM7_IMP(ICompressGetSubStreamSize)
|
||||
Z7_IFACE_COM7_IMP(ICompressInSubStreams)
|
||||
|
||||
CMyComPtr<ISequentialInStream> _stream;
|
||||
CMyComPtr<ICompressGetSubStreamSize> _getSubStreamSize;
|
||||
CMyComPtr<ICompressInSubStreams> _compressGetSubStreamSize;
|
||||
UInt64 _size;
|
||||
public:
|
||||
void Init(ISequentialInStream *stream)
|
||||
{
|
||||
_size = 0;
|
||||
_getSubStreamSize.Release();
|
||||
_compressGetSubStreamSize.Release();
|
||||
_stream = stream;
|
||||
_stream.QueryInterface(IID_ICompressGetSubStreamSize, &_getSubStreamSize);
|
||||
_stream.QueryInterface(IID_ICompressInSubStreams, &_compressGetSubStreamSize);
|
||||
}
|
||||
UInt64 GetSize() const { return _size; }
|
||||
|
||||
MY_UNKNOWN_IMP2(ISequentialInStream, ICompressGetSubStreamSize)
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
|
||||
STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value);
|
||||
};
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
// 7zUpdate.h
|
||||
|
||||
#ifndef __7Z_UPDATE_H
|
||||
#define __7Z_UPDATE_H
|
||||
#ifndef ZIP7_INC_7Z_UPDATE_H
|
||||
#define ZIP7_INC_7Z_UPDATE_H
|
||||
|
||||
#include "../IArchive.h"
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "7zCompressionMode.h"
|
||||
#include "7zIn.h"
|
||||
#include "7zOut.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
@@ -95,8 +94,6 @@ struct CUpdateOptions
|
||||
bool MaxFilter; // use BCJ2 filter instead of BCJ
|
||||
int AnalysisLevel;
|
||||
|
||||
CHeaderOptions HeaderOptions;
|
||||
|
||||
UInt64 NumSolidFiles;
|
||||
UInt64 NumSolidBytes;
|
||||
bool SolidExtension;
|
||||
@@ -110,6 +107,9 @@ struct CUpdateOptions
|
||||
bool Need_ATime;
|
||||
bool Need_MTime;
|
||||
bool Need_Attrib;
|
||||
// bool Need_Crc;
|
||||
|
||||
CHeaderOptions HeaderOptions;
|
||||
|
||||
CUpdateOptions():
|
||||
Method(NULL),
|
||||
@@ -127,6 +127,7 @@ struct CUpdateOptions
|
||||
Need_ATime(false),
|
||||
Need_MTime(false),
|
||||
Need_Attrib(false)
|
||||
// , Need_Crc(true)
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -134,18 +135,12 @@ HRESULT Update(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
const CDbEx *db,
|
||||
const CObjectVector<CUpdateItem> &updateItems,
|
||||
CObjectVector<CUpdateItem> &updateItems,
|
||||
// const CObjectVector<CTreeFolder> &treeFolders, // treeFolders[0] is root
|
||||
// const CUniqBlocks &secureBlocks,
|
||||
COutArchive &archive,
|
||||
CArchiveDatabaseOut &newDatabase,
|
||||
ISequentialOutStream *seqOutStream,
|
||||
IArchiveUpdateCallback *updateCallback,
|
||||
const CUpdateOptions &options
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getDecoderPassword
|
||||
#endif
|
||||
);
|
||||
const CUpdateOptions &options);
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
#ifndef ZIP7_INC_STDAFX_H
|
||||
#define ZIP7_INC_STDAFX_H
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
#pragma warning(disable : 4464) // relative include path contains '..'
|
||||
#endif
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
PROG = 7z.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-DEXTERNAL_CODECS \
|
||||
-DZ7_EXTERNAL_CODECS \
|
||||
|
||||
AR_OBJS = \
|
||||
$O\ArchiveExports.obj \
|
||||
$O\DllExports.obj \
|
||||
$O\DllExports2.obj \
|
||||
|
||||
7Z_OBJS = \
|
||||
$O\7zCompressionMode.obj \
|
||||
@@ -34,7 +34,6 @@ COMMON_OBJS = \
|
||||
$O\Wildcard.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\DLL.obj \
|
||||
$O\FileDir.obj \
|
||||
$O\FileFind.obj \
|
||||
$O\FileIO.obj \
|
||||
@@ -61,6 +60,7 @@ WIN_OBJS = \
|
||||
|
||||
COMPRESS_OBJS = \
|
||||
$O\CopyCoder.obj \
|
||||
$O\CodecExports.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CoderMixer2.obj \
|
||||
|
||||
Reference in New Issue
Block a user