mirror of
https://github.com/Xevion/easy7zip.git
synced 2026-01-31 10:24:13 -06:00
4.45 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
d9666cf046
commit
a145bfc7cf
+65
-55
@@ -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 "COMPRESS_MT" /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 "COMPRESS_MT" /D "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"
|
||||
@@ -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 "COMPRESS_MT" /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 "COMPRESS_MT" /D "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"
|
||||
@@ -97,7 +97,11 @@ SOURCE=..\Archive.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
SOURCE=..\ArchiveExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -194,22 +198,6 @@ SOURCE=.\7zItem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zMethodID.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zMethodID.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zMethods.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zMethods.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -226,6 +214,10 @@ SOURCE=.\7zProperties.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zRegister.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7zSpecStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -278,14 +270,6 @@ SOURCE=..\..\PropID.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Buffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -294,10 +278,6 @@ SOURCE=..\..\..\Common\CRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\DynamicBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -354,22 +334,6 @@ SOURCE=..\..\..\Common\Vector.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CodecsPath.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CodecsPath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderLoader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderLoader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\CoderMixer2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -394,14 +358,6 @@ SOURCE=..\Common\CrossThreadProgress.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\FilterCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\FilterCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\InStreamWithCRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -446,6 +402,22 @@ SOURCE=..\Common\ParseProperties.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CreateCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CreateCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilterCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilterCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InOutTempBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -470,6 +442,14 @@ SOURCE=..\..\Common\LockedStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\MethodId.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\MethodId.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\OutBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -486,6 +466,14 @@ SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\RegisterArc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\RegisterCodec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamBinder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -585,6 +573,28 @@ SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "C"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\7z.ico
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
#ifndef __7Z_COMPRESSION_MODE_H
|
||||
#define __7Z_COMPRESSION_MODE_H
|
||||
|
||||
#include "../../../Common/String.h"
|
||||
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
|
||||
#include "7zMethodID.h"
|
||||
#include "../../Common/MethodID.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
@@ -18,18 +20,10 @@ struct CProperty
|
||||
|
||||
struct CMethodFull
|
||||
{
|
||||
CMethodID MethodID;
|
||||
CMethodId MethodID;
|
||||
UInt32 NumInStreams;
|
||||
UInt32 NumOutStreams;
|
||||
bool IsSimpleCoder() const
|
||||
{ return (NumInStreams == 1) && (NumOutStreams == 1); }
|
||||
|
||||
#ifdef EXCLUDE_COM
|
||||
#else
|
||||
CLSID EncoderClassID;
|
||||
CSysString FilePath;
|
||||
#endif
|
||||
|
||||
bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
|
||||
CObjectVector<CProperty> CoderProperties;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,61 +9,8 @@
|
||||
#include "../../Common/StreamObjects.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
#include "../Common/FilterCoder.h"
|
||||
|
||||
#include "7zMethods.h"
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
#include "../../Compress/LZMA/LZMADecoder.h"
|
||||
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
#include "../../Compress/PPMD/PPMDDecoder.h"
|
||||
static NArchive::N7z::CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
#include "../../Compress/Branch/x86.h"
|
||||
static NArchive::N7z::CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ2
|
||||
#include "../../Compress/Branch/x86_2.h"
|
||||
static NArchive::N7z::CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE
|
||||
#ifndef COMPRESS_DEFLATE_DECODER
|
||||
#define COMPRESS_DEFLATE_DECODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_DECODER
|
||||
#include "../../Compress/Deflate/DeflateDecoder.h"
|
||||
static NArchive::N7z::CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2
|
||||
#ifndef COMPRESS_BZIP2_DECODER
|
||||
#define COMPRESS_BZIP2_DECODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_DECODER
|
||||
#include "../../Compress/BZip2/BZip2Decoder.h"
|
||||
static NArchive::N7z::CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
static NArchive::N7z::CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTO_7ZAES
|
||||
#include "../../Crypto/7zAES/7zAES.h"
|
||||
static NArchive::N7z::CMethodID k_7zAES = { { 0x6, 0xF1, 0x07, 0x01 }, 4 };
|
||||
#endif
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../Common/FilterCoder.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
@@ -88,8 +35,7 @@ static void ConvertFolderItemInfoToBindInfo(const CFolder &folder,
|
||||
coderStreamsInfo.NumInStreams = (UInt32)coderInfo.NumInStreams;
|
||||
coderStreamsInfo.NumOutStreams = (UInt32)coderInfo.NumOutStreams;
|
||||
bindInfo.Coders.Add(coderStreamsInfo);
|
||||
const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
|
||||
bindInfo.CoderMethodIDs.Add(altCoderInfo.MethodID);
|
||||
bindInfo.CoderMethodIDs.Add(coderInfo.MethodID);
|
||||
for (UInt32 j = 0; j < coderStreamsInfo.NumOutStreams; j++, outStreamIndex++)
|
||||
if (folder.FindBindPairForOutStream(outStreamIndex) < 0)
|
||||
bindInfo.OutStreams.Add(outStreamIndex);
|
||||
@@ -141,12 +87,11 @@ CDecoder::CDecoder(bool multiThread)
|
||||
#endif
|
||||
_multiThread = multiThread;
|
||||
_bindInfoExPrevIsDefined = false;
|
||||
#ifndef EXCLUDE_COM
|
||||
LoadMethodMap();
|
||||
#endif
|
||||
}
|
||||
|
||||
HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
HRESULT CDecoder::Decode(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
UInt64 startPos,
|
||||
const UInt64 *packSizes,
|
||||
const CFolder &folderInfo,
|
||||
@@ -217,72 +162,21 @@ HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
for (i = 0; i < numCoders; i++)
|
||||
{
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
|
||||
#ifndef EXCLUDE_COM
|
||||
CMethodInfo methodInfo;
|
||||
if (!GetMethodInfo(altCoderInfo.MethodID, methodInfo))
|
||||
return E_NOTIMPL;
|
||||
#endif
|
||||
|
||||
|
||||
CMyComPtr<ICompressCoder> decoder;
|
||||
CMyComPtr<ICompressCoder2> decoder2;
|
||||
RINOK(CreateCoder(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
coderInfo.MethodID, decoder, decoder2, false));
|
||||
CMyComPtr<IUnknown> decoderUnknown;
|
||||
if (coderInfo.IsSimpleCoder())
|
||||
{
|
||||
CMyComPtr<ICompressCoder> decoder;
|
||||
CMyComPtr<ICompressFilter> filter;
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
if (altCoderInfo.MethodID == k_LZMA)
|
||||
decoder = new NCompress::NLZMA::CDecoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
if (altCoderInfo.MethodID == k_PPMD)
|
||||
decoder = new NCompress::NPPMD::CDecoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
if (altCoderInfo.MethodID == k_BCJ_X86)
|
||||
filter = new CBCJ_x86_Decoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_DECODER
|
||||
if (altCoderInfo.MethodID == k_Deflate)
|
||||
decoder = new NCompress::NDeflate::NDecoder::CCOMCoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_DECODER
|
||||
if (altCoderInfo.MethodID == k_BZip2)
|
||||
decoder = new NCompress::NBZip2::CDecoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
if (altCoderInfo.MethodID == k_Copy)
|
||||
decoder = new NCompress::CCopyCoder;
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTO_7ZAES
|
||||
if (altCoderInfo.MethodID == k_7zAES)
|
||||
filter = new NCrypto::NSevenZ::CDecoder;
|
||||
#endif
|
||||
|
||||
if (filter)
|
||||
{
|
||||
CFilterCoder *coderSpec = new CFilterCoder;
|
||||
decoder = coderSpec;
|
||||
coderSpec->Filter = filter;
|
||||
}
|
||||
#ifndef EXCLUDE_COM
|
||||
if (decoder == 0)
|
||||
{
|
||||
RINOK(_libraries.CreateCoderSpec(methodInfo.FilePath,
|
||||
methodInfo.Decoder, &decoder));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (decoder == 0)
|
||||
return E_NOTIMPL;
|
||||
|
||||
_decoders.Add((IUnknown *)decoder);
|
||||
|
||||
decoderUnknown = (IUnknown *)decoder;
|
||||
|
||||
if (_multiThread)
|
||||
_mixerCoderMTSpec->AddCoder(decoder);
|
||||
#ifdef _ST_MODE
|
||||
@@ -292,32 +186,25 @@ HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
}
|
||||
else
|
||||
{
|
||||
CMyComPtr<ICompressCoder2> decoder;
|
||||
|
||||
#ifdef COMPRESS_BCJ2
|
||||
if (altCoderInfo.MethodID == k_BCJ2)
|
||||
decoder = new CBCJ2_x86_Decoder;
|
||||
#endif
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
if (decoder == 0)
|
||||
{
|
||||
RINOK(_libraries.CreateCoder2(methodInfo.FilePath,
|
||||
methodInfo.Decoder, &decoder));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (decoder == 0)
|
||||
if (decoder2 == 0)
|
||||
return E_NOTIMPL;
|
||||
|
||||
_decoders.Add((IUnknown *)decoder);
|
||||
decoderUnknown = (IUnknown *)decoder2;
|
||||
if (_multiThread)
|
||||
_mixerCoderMTSpec->AddCoder2(decoder);
|
||||
_mixerCoderMTSpec->AddCoder2(decoder2);
|
||||
#ifdef _ST_MODE
|
||||
else
|
||||
_mixerCoderSTSpec->AddCoder2(decoder, false);
|
||||
_mixerCoderSTSpec->AddCoder2(decoder2, false);
|
||||
#endif
|
||||
}
|
||||
_decoders.Add(decoderUnknown);
|
||||
#ifdef EXTERNAL_CODECS
|
||||
CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
|
||||
decoderUnknown.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
|
||||
if (setCompressCodecsInfo)
|
||||
{
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecsInfo));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
_bindInfoExPrev = bindInfo;
|
||||
_bindInfoExPrevIsDefined = true;
|
||||
@@ -332,7 +219,6 @@ HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
for (i = 0; i < numCoders; i++)
|
||||
{
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
|
||||
CMyComPtr<IUnknown> &decoder = _decoders[coderIndex];
|
||||
|
||||
{
|
||||
@@ -340,7 +226,7 @@ HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
decoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
|
||||
if (setDecoderProperties)
|
||||
{
|
||||
const CByteBuffer &properties = altCoderInfo.Properties;
|
||||
const CByteBuffer &properties = coderInfo.Properties;
|
||||
size_t size = properties.GetCapacity();
|
||||
if (size > 0xFFFFFFFF)
|
||||
return E_NOTIMPL;
|
||||
|
||||
@@ -11,9 +11,8 @@
|
||||
#ifdef _ST_MODE
|
||||
#include "../Common/CoderMixer2ST.h"
|
||||
#endif
|
||||
#ifndef EXCLUDE_COM
|
||||
#include "../Common/CoderLoader.h"
|
||||
#endif
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
#include "7zItem.h"
|
||||
|
||||
@@ -22,7 +21,7 @@ namespace N7z {
|
||||
|
||||
struct CBindInfoEx: public NCoderMixer2::CBindInfo
|
||||
{
|
||||
CRecordVector<CMethodID> CoderMethodIDs;
|
||||
CRecordVector<CMethodId> CoderMethodIDs;
|
||||
void Clear()
|
||||
{
|
||||
CBindInfo::Clear();
|
||||
@@ -32,10 +31,6 @@ struct CBindInfoEx: public NCoderMixer2::CBindInfo
|
||||
|
||||
class CDecoder
|
||||
{
|
||||
#ifndef EXCLUDE_COM
|
||||
CCoderLibraries _libraries;
|
||||
#endif
|
||||
|
||||
bool _bindInfoExPrevIsDefined;
|
||||
CBindInfoEx _bindInfoExPrev;
|
||||
|
||||
@@ -51,7 +46,9 @@ class CDecoder
|
||||
// CObjectVector<CMyComPtr<ICompressCoder2> > _decoders2;
|
||||
public:
|
||||
CDecoder(bool multiThread);
|
||||
HRESULT Decode(IInStream *inStream,
|
||||
HRESULT Decode(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
UInt64 startPos,
|
||||
const UInt64 *packSizes,
|
||||
const CFolder &folder,
|
||||
|
||||
@@ -4,84 +4,24 @@
|
||||
|
||||
#include "7zEncode.h"
|
||||
#include "7zSpecStream.h"
|
||||
#include "7zMethods.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
#include "../../Common/InOutTempBuffer.h"
|
||||
#include "../../Common/StreamObjects.h"
|
||||
#include "../Common/FilterCoder.h"
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../Common/FilterCoder.h"
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
static NArchive::N7z::CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
#endif
|
||||
|
||||
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
static NArchive::N7z::CMethodID k_LZMA2 = { { 0x3, 0x1, 0x2 }, 3 };
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
#include "../../Compress/LZMA/LZMAEncoder.h"
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
#include "../../Compress/PPMD/PPMDEncoder.h"
|
||||
static NArchive::N7z::CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
static NArchive::N7z::CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
#include "../../Compress/Branch/x86.h"
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ2
|
||||
static NArchive::N7z::CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
|
||||
#include "../../Compress/Branch/x86_2.h"
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE
|
||||
#ifndef COMPRESS_DEFLATE_ENCODER
|
||||
#define COMPRESS_DEFLATE_ENCODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_ENCODER
|
||||
#include "../../Compress/Deflate/DeflateEncoder.h"
|
||||
static NArchive::N7z::CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2
|
||||
#ifndef COMPRESS_BZIP2_ENCODER
|
||||
#define COMPRESS_BZIP2_ENCODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_ENCODER
|
||||
#include "../../Compress/BZip2/BZip2Encoder.h"
|
||||
static NArchive::N7z::CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
|
||||
#endif
|
||||
|
||||
static NArchive::N7z::CMethodID k_AES = { { 0x6, 0xF1, 0x7, 0x1}, 4 };
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
static const wchar_t *kCryproMethod = L"7zAES";
|
||||
/*
|
||||
// {23170F69-40C1-278B-06F1-070100000100}
|
||||
DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x01, 0x00);
|
||||
*/
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTO_7ZAES
|
||||
#include "../../Crypto/7zAES/7zAES.h"
|
||||
#endif
|
||||
static UInt64 k_LZMA = 0x030101;
|
||||
// static UInt64 k_LZMA2 = 0x030102;
|
||||
static UInt64 k_AES = 0x06F10701;
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
static void ConvertBindInfoToFolderItemInfo(const NCoderMixer2::CBindInfo &bindInfo,
|
||||
const CRecordVector<CMethodID> decompressionMethods,
|
||||
const CRecordVector<CMethodId> decompressionMethods,
|
||||
CFolder &folder)
|
||||
{
|
||||
folder.Coders.Clear();
|
||||
@@ -103,20 +43,16 @@ static void ConvertBindInfoToFolderItemInfo(const NCoderMixer2::CBindInfo &bindI
|
||||
const NCoderMixer2::CCoderStreamsInfo &coderStreamsInfo = bindInfo.Coders[i];
|
||||
coderInfo.NumInStreams = coderStreamsInfo.NumInStreams;
|
||||
coderInfo.NumOutStreams = coderStreamsInfo.NumOutStreams;
|
||||
|
||||
// coderInfo.MethodID = decompressionMethods[i];
|
||||
// if (coderInfo.AltCoders.Size() == 0)
|
||||
coderInfo.AltCoders.Add(CAltCoderInfo());
|
||||
CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
|
||||
altCoderInfo.MethodID = decompressionMethods[i];
|
||||
|
||||
coderInfo.MethodID = decompressionMethods[i];
|
||||
folder.Coders.Add(coderInfo);
|
||||
}
|
||||
for (i = 0; i < bindInfo.InStreams.Size(); i++)
|
||||
folder.PackStreams.Add(bindInfo.InStreams[i]);
|
||||
}
|
||||
|
||||
HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
HRESULT CEncoder::CreateMixerCoder(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const UInt64 *inSizeForReduce)
|
||||
{
|
||||
_mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT;
|
||||
_mixerCoder = _mixerCoderSpec;
|
||||
@@ -127,88 +63,19 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
_codersInfo.Add(CCoderInfo());
|
||||
CCoderInfo &encodingInfo = _codersInfo.Back();
|
||||
CMyComPtr<ICompressCoder> encoder;
|
||||
CMyComPtr<ICompressFilter> filter;
|
||||
CMyComPtr<ICompressCoder2> encoder2;
|
||||
|
||||
if (methodFull.IsSimpleCoder())
|
||||
{
|
||||
#ifdef COMPRESS_LZMA
|
||||
if (methodFull.MethodID == k_LZMA)
|
||||
encoder = new NCompress::NLZMA::CEncoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
if (methodFull.MethodID == k_PPMD)
|
||||
encoder = new NCompress::NPPMD::CEncoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
if (methodFull.MethodID == k_BCJ_X86)
|
||||
filter = new CBCJ_x86_Encoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
if (methodFull.MethodID == k_Copy)
|
||||
encoder = new NCompress::CCopyCoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_ENCODER
|
||||
if (methodFull.MethodID == k_BZip2)
|
||||
encoder = new NCompress::NBZip2::CEncoder;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_ENCODER
|
||||
if (methodFull.MethodID == k_Deflate)
|
||||
encoder = new NCompress::NDeflate::NEncoder::CCOMCoder;
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTO_7ZAES
|
||||
if (methodFull.MethodID == k_AES)
|
||||
filter = new NCrypto::NSevenZ::CEncoder;
|
||||
#endif
|
||||
|
||||
if (filter)
|
||||
{
|
||||
CFilterCoder *coderSpec = new CFilterCoder;
|
||||
encoder = coderSpec;
|
||||
coderSpec->Filter = filter;
|
||||
}
|
||||
RINOK(CreateCoder(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
methodFull.MethodID, encoder, encoder2, true));
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
if (encoder == 0)
|
||||
{
|
||||
RINOK(_libraries.CreateCoderSpec(methodFull.FilePath,
|
||||
methodFull.EncoderClassID, &encoder));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (encoder == 0)
|
||||
return E_FAIL;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef COMPRESS_BCJ2
|
||||
if (methodFull.MethodID == k_BCJ2)
|
||||
encoder2 = new CBCJ2_x86_Encoder;
|
||||
#endif
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
if (encoder2 == 0)
|
||||
{
|
||||
RINOK(_libraries.CreateCoder2(methodFull.FilePath,
|
||||
methodFull.EncoderClassID, &encoder2));
|
||||
}
|
||||
#else
|
||||
|
||||
if (encoder2 == 0)
|
||||
return E_FAIL;
|
||||
#endif
|
||||
}
|
||||
if (!encoder && !encoder2)
|
||||
return E_FAIL;
|
||||
|
||||
bool tryReduce = false;
|
||||
UInt32 reducedDictionarySize = 1 << 10;
|
||||
if (inSizeForReduce != 0 && (methodFull.MethodID == k_LZMA || methodFull.MethodID == k_LZMA2))
|
||||
if (inSizeForReduce != 0 && (methodFull.MethodID == k_LZMA /* || methodFull.MethodID == k_LZMA2 */))
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@@ -230,7 +97,7 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
}
|
||||
}
|
||||
|
||||
CMyComPtr<IUnknown> encoderCommon = methodFull.IsSimpleCoder() ? (IUnknown *)encoder : (IUnknown *)encoder2;
|
||||
CMyComPtr<IUnknown> encoderCommon = encoder ? (IUnknown *)encoder : (IUnknown *)encoder2;
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
{
|
||||
@@ -284,14 +151,18 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
|
||||
size_t size = outStreamSpec->GetSize();
|
||||
|
||||
// encodingInfo.Properties.SetCapacity(size);
|
||||
if (encodingInfo.AltCoders.Size() == 0)
|
||||
encodingInfo.AltCoders.Add(CAltCoderInfo());
|
||||
CAltCoderInfo &altCoderInfo = encodingInfo.AltCoders.Front();
|
||||
altCoderInfo.Properties.SetCapacity(size);
|
||||
|
||||
memmove(altCoderInfo.Properties, outStreamSpec->GetBuffer(), size);
|
||||
encodingInfo.Properties.SetCapacity(size);
|
||||
memmove(encodingInfo.Properties, outStreamSpec->GetBuffer(), size);
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
|
||||
encoderCommon.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
|
||||
if (setCompressCodecsInfo)
|
||||
{
|
||||
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecsInfo));
|
||||
}
|
||||
#endif
|
||||
|
||||
CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
|
||||
encoderCommon.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword);
|
||||
@@ -310,7 +181,7 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, sizeInBytes));
|
||||
}
|
||||
|
||||
if (methodFull.IsSimpleCoder())
|
||||
if (encoder)
|
||||
_mixerCoderSpec->AddCoder(encoder);
|
||||
else
|
||||
_mixerCoderSpec->AddCoder2(encoder2);
|
||||
@@ -318,16 +189,20 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CEncoder::Encode(ISequentialInStream *inStream,
|
||||
HRESULT CEncoder::Encode(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
ISequentialInStream *inStream,
|
||||
const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
|
||||
CFolder &folderItem,
|
||||
ISequentialOutStream *outStream,
|
||||
CRecordVector<UInt64> &packSizes,
|
||||
ICompressProgressInfo *compressProgress)
|
||||
{
|
||||
RINOK(EncoderConstr());
|
||||
|
||||
if (_mixerCoderSpec == NULL)
|
||||
{
|
||||
RINOK(CreateMixerCoder(inSizeForReduce));
|
||||
RINOK(CreateMixerCoder(EXTERNAL_CODECS_LOC_VARS inSizeForReduce));
|
||||
}
|
||||
_mixerCoderSpec->ReInit();
|
||||
// _mixerCoderSpec->SetCoderInfo(0, NULL, NULL, progress);
|
||||
@@ -423,50 +298,41 @@ HRESULT CEncoder::Encode(ISequentialInStream *inStream,
|
||||
folderItem.UnPackSizes.Add(streamSize);
|
||||
}
|
||||
for (i = numMethods - 1; i >= 0; i--)
|
||||
{
|
||||
// folderItem.Coders[numMethods - 1 - i].Properties = _codersInfo[i].Properties;
|
||||
for (int j = 0; j < _codersInfo[i].AltCoders.Size(); j++)
|
||||
folderItem.Coders[numMethods - 1 - i].AltCoders[j].Properties
|
||||
= _codersInfo[i].AltCoders[j].Properties;
|
||||
}
|
||||
folderItem.Coders[numMethods - 1 - i].Properties = _codersInfo[i].Properties;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
CEncoder::CEncoder(const CCompressionMethodMode &options):
|
||||
_bindReverseConverter(0)
|
||||
_bindReverseConverter(0),
|
||||
_constructed(false)
|
||||
{
|
||||
if (options.IsEmpty())
|
||||
throw 1;
|
||||
|
||||
_options = options;
|
||||
_mixerCoderSpec = NULL;
|
||||
}
|
||||
|
||||
if (options.Methods.IsEmpty())
|
||||
HRESULT CEncoder::EncoderConstr()
|
||||
{
|
||||
if (_constructed)
|
||||
return S_OK;
|
||||
if (_options.Methods.IsEmpty())
|
||||
{
|
||||
// it has only password method;
|
||||
if (!options.PasswordIsDefined)
|
||||
if (!_options.PasswordIsDefined)
|
||||
throw 1;
|
||||
if (!options.Binds.IsEmpty())
|
||||
if (!_options.Binds.IsEmpty())
|
||||
throw 1;
|
||||
NCoderMixer2::CCoderStreamsInfo coderStreamsInfo;
|
||||
CMethodFull method;
|
||||
|
||||
method.NumInStreams = 1;
|
||||
method.NumOutStreams = 1;
|
||||
coderStreamsInfo.NumInStreams = method.NumOutStreams;
|
||||
coderStreamsInfo.NumOutStreams = method.NumInStreams;
|
||||
coderStreamsInfo.NumInStreams = 1;
|
||||
coderStreamsInfo.NumOutStreams = 1;
|
||||
method.MethodID = k_AES;
|
||||
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
CMethodInfo2 methodInfo;
|
||||
if (!GetMethodInfo(kCryproMethod, methodInfo))
|
||||
throw 2;
|
||||
method.FilePath = methodInfo.FilePath;
|
||||
method.EncoderClassID = methodInfo.Encoder;
|
||||
// method.EncoderClassID = CLSID_CCrypto7zAESEncoder;
|
||||
#endif
|
||||
|
||||
_options.Methods.Add(method);
|
||||
_bindInfo.Coders.Add(coderStreamsInfo);
|
||||
@@ -479,15 +345,15 @@ CEncoder::CEncoder(const CCompressionMethodMode &options):
|
||||
|
||||
UInt32 numInStreams = 0, numOutStreams = 0;
|
||||
int i;
|
||||
for (i = 0; i < options.Methods.Size(); i++)
|
||||
for (i = 0; i < _options.Methods.Size(); i++)
|
||||
{
|
||||
const CMethodFull &methodFull = options.Methods[i];
|
||||
const CMethodFull &methodFull = _options.Methods[i];
|
||||
NCoderMixer2::CCoderStreamsInfo coderStreamsInfo;
|
||||
coderStreamsInfo.NumInStreams = methodFull.NumOutStreams;
|
||||
coderStreamsInfo.NumOutStreams = methodFull.NumInStreams;
|
||||
if (options.Binds.IsEmpty())
|
||||
if (_options.Binds.IsEmpty())
|
||||
{
|
||||
if (i < options.Methods.Size() - 1)
|
||||
if (i < _options.Methods.Size() - 1)
|
||||
{
|
||||
NCoderMixer2::CBindPair bindPair;
|
||||
bindPair.InIndex = numInStreams + coderStreamsInfo.NumInStreams;
|
||||
@@ -506,12 +372,12 @@ CEncoder::CEncoder(const CCompressionMethodMode &options):
|
||||
_bindInfo.Coders.Add(coderStreamsInfo);
|
||||
}
|
||||
|
||||
if (!options.Binds.IsEmpty())
|
||||
if (!_options.Binds.IsEmpty())
|
||||
{
|
||||
for (i = 0; i < options.Binds.Size(); i++)
|
||||
for (i = 0; i < _options.Binds.Size(); i++)
|
||||
{
|
||||
NCoderMixer2::CBindPair bindPair;
|
||||
const CBind &bind = options.Binds[i];
|
||||
const CBind &bind = _options.Binds[i];
|
||||
bindPair.InIndex = _bindInfo.GetCoderInStreamIndex(bind.InCoder) + bind.InStream;
|
||||
bindPair.OutIndex = _bindInfo.GetCoderOutStreamIndex(bind.OutCoder) + bind.OutStream;
|
||||
_bindInfo.BindPairs.Add(bindPair);
|
||||
@@ -579,15 +445,6 @@ CEncoder::CEncoder(const CCompressionMethodMode &options):
|
||||
coderStreamsInfo.NumOutStreams = method.NumInStreams;
|
||||
method.MethodID = k_AES;
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
CMethodInfo2 methodInfo;
|
||||
if (!GetMethodInfo(kCryproMethod, methodInfo))
|
||||
throw 2;
|
||||
method.FilePath = methodInfo.FilePath;
|
||||
method.EncoderClassID = methodInfo.Encoder;
|
||||
// method.EncoderClassID = CLSID_CCrypto7zAESEncoder;
|
||||
#endif
|
||||
|
||||
_options.Methods.Add(method);
|
||||
_bindInfo.Coders.Add(coderStreamsInfo);
|
||||
_bindInfo.OutStreams.Add(numOutStreams + i);
|
||||
@@ -604,6 +461,8 @@ CEncoder::CEncoder(const CCompressionMethodMode &options):
|
||||
|
||||
_bindReverseConverter = new NCoderMixer2::CBindReverseConverter(_bindInfo);
|
||||
_bindReverseConverter->CreateReverseBindInfo(_decompressBindInfo);
|
||||
_constructed = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CEncoder::~CEncoder()
|
||||
|
||||
@@ -12,23 +12,15 @@
|
||||
#ifdef _ST_MODE
|
||||
#include "../Common/CoderMixer2ST.h"
|
||||
#endif
|
||||
#ifndef EXCLUDE_COM
|
||||
#include "../Common/CoderLoader.h"
|
||||
#endif
|
||||
#include "7zMethods.h"
|
||||
#include "7zItem.h"
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
class CEncoder
|
||||
{
|
||||
#ifndef EXCLUDE_COM
|
||||
// CMethodMap _methodMap;
|
||||
// it must be in top of objects
|
||||
CCoderLibraries _libraries;
|
||||
#endif
|
||||
|
||||
NCoderMixer2::CCoderMixer2MT *_mixerCoderSpec;
|
||||
CMyComPtr<ICompressCoder2> _mixerCoder;
|
||||
|
||||
@@ -38,14 +30,19 @@ class CEncoder
|
||||
NCoderMixer2::CBindInfo _bindInfo;
|
||||
NCoderMixer2::CBindInfo _decompressBindInfo;
|
||||
NCoderMixer2::CBindReverseConverter *_bindReverseConverter;
|
||||
CRecordVector<CMethodID> _decompressionMethods;
|
||||
CRecordVector<CMethodId> _decompressionMethods;
|
||||
|
||||
HRESULT CreateMixerCoder(const UInt64 *inSizeForReduce);
|
||||
HRESULT CreateMixerCoder(DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const UInt64 *inSizeForReduce);
|
||||
|
||||
bool _constructed;
|
||||
public:
|
||||
CEncoder(const CCompressionMethodMode &options);
|
||||
~CEncoder();
|
||||
HRESULT Encode(ISequentialInStream *inStream,
|
||||
HRESULT EncoderConstr();
|
||||
HRESULT Encode(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
ISequentialInStream *inStream,
|
||||
const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
|
||||
CFolder &folderItem,
|
||||
ISequentialOutStream *outStream,
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "7zHandler.h"
|
||||
#include "7zFolderOutStream.h"
|
||||
#include "7zMethods.h"
|
||||
#include "7zDecode.h"
|
||||
// #include "7z1Decode.h"
|
||||
|
||||
@@ -216,6 +215,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
try
|
||||
{
|
||||
HRESULT result = decoder.Decode(
|
||||
EXTERNAL_CODECS_VARS
|
||||
#ifdef _7Z_VOL
|
||||
volume.Stream,
|
||||
#else
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
extern UString ConvertMethodIdToString(UInt64 id);
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
@@ -33,9 +35,6 @@ CHandler::CHandler()
|
||||
#ifndef EXTRACT_ONLY
|
||||
Init();
|
||||
#endif
|
||||
#ifndef EXCLUDE_COM
|
||||
LoadMethodMap();
|
||||
#endif
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
@@ -124,14 +123,9 @@ static UString GetStringForSizeValue(UInt32 value)
|
||||
return result;
|
||||
}
|
||||
|
||||
static CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
static CMethodID k_BCJ = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
|
||||
static CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
|
||||
static CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
|
||||
static CMethodID k_Deflate64 = { { 0x4, 0x1, 0x9 }, 3 };
|
||||
static CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
|
||||
static const UInt64 k_Copy = 0x0;
|
||||
static const UInt64 k_LZMA = 0x030101;
|
||||
static const UInt64 k_PPMD = 0x030401;
|
||||
|
||||
static wchar_t GetHex(Byte value)
|
||||
{
|
||||
@@ -147,7 +141,7 @@ static inline UString GetHex2(Byte value)
|
||||
|
||||
#endif
|
||||
|
||||
static CMethodID k_AES = { { 0x6, 0xF1, 0x7, 0x1}, 4 };
|
||||
static const UInt64 k_AES = 0x06F10701;
|
||||
|
||||
static inline UInt32 GetUInt32FromMemLE(const Byte *p)
|
||||
{
|
||||
@@ -161,12 +155,8 @@ bool CHandler::IsEncrypted(UInt32 index2) const
|
||||
{
|
||||
const CFolder &folderInfo = _database.Folders[folderIndex];
|
||||
for (int i = folderInfo.Coders.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
for (int j = 0; j < coderInfo.AltCoders.Size(); j++)
|
||||
if (coderInfo.AltCoders[j].MethodID == k_AES)
|
||||
return true;
|
||||
}
|
||||
if (folderInfo.Coders[i].MethodID == k_AES)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -276,81 +266,45 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
if (!methodsString.IsEmpty())
|
||||
methodsString += L' ';
|
||||
CMethodInfo methodInfo;
|
||||
|
||||
bool methodIsKnown;
|
||||
|
||||
for (int j = 0; j < coderInfo.AltCoders.Size(); j++)
|
||||
{
|
||||
if (j > 0)
|
||||
methodsString += L"|";
|
||||
const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders[j];
|
||||
|
||||
UString methodName;
|
||||
#ifdef NO_REGISTRY
|
||||
|
||||
methodIsKnown = true;
|
||||
if (altCoderInfo.MethodID == k_Copy)
|
||||
methodName = L"Copy";
|
||||
else if (altCoderInfo.MethodID == k_LZMA)
|
||||
methodName = L"LZMA";
|
||||
else if (altCoderInfo.MethodID == k_BCJ)
|
||||
methodName = L"BCJ";
|
||||
else if (altCoderInfo.MethodID == k_BCJ2)
|
||||
methodName = L"BCJ2";
|
||||
else if (altCoderInfo.MethodID == k_PPMD)
|
||||
methodName = L"PPMD";
|
||||
else if (altCoderInfo.MethodID == k_Deflate)
|
||||
methodName = L"Deflate";
|
||||
else if (altCoderInfo.MethodID == k_Deflate64)
|
||||
methodName = L"Deflate64";
|
||||
else if (altCoderInfo.MethodID == k_BZip2)
|
||||
methodName = L"BZip2";
|
||||
else if (altCoderInfo.MethodID == k_AES)
|
||||
methodName = L"7zAES";
|
||||
else
|
||||
methodIsKnown = false;
|
||||
|
||||
#else
|
||||
|
||||
methodIsKnown = GetMethodInfo(
|
||||
altCoderInfo.MethodID, methodInfo);
|
||||
methodName = methodInfo.Name;
|
||||
|
||||
#endif
|
||||
bool methodIsKnown = FindMethod(
|
||||
EXTERNAL_CODECS_VARS
|
||||
coderInfo.MethodID, methodName);
|
||||
|
||||
if (methodIsKnown)
|
||||
{
|
||||
methodsString += methodName;
|
||||
if (altCoderInfo.MethodID == k_LZMA)
|
||||
if (coderInfo.MethodID == k_LZMA)
|
||||
{
|
||||
if (altCoderInfo.Properties.GetCapacity() >= 5)
|
||||
if (coderInfo.Properties.GetCapacity() >= 5)
|
||||
{
|
||||
methodsString += L":";
|
||||
UInt32 dicSize = GetUInt32FromMemLE(
|
||||
((const Byte *)altCoderInfo.Properties + 1));
|
||||
((const Byte *)coderInfo.Properties + 1));
|
||||
methodsString += GetStringForSizeValue(dicSize);
|
||||
}
|
||||
}
|
||||
else if (altCoderInfo.MethodID == k_PPMD)
|
||||
else if (coderInfo.MethodID == k_PPMD)
|
||||
{
|
||||
if (altCoderInfo.Properties.GetCapacity() >= 5)
|
||||
if (coderInfo.Properties.GetCapacity() >= 5)
|
||||
{
|
||||
Byte order = *(const Byte *)altCoderInfo.Properties;
|
||||
Byte order = *(const Byte *)coderInfo.Properties;
|
||||
methodsString += L":o";
|
||||
methodsString += ConvertUInt32ToString(order);
|
||||
methodsString += L":mem";
|
||||
UInt32 dicSize = GetUInt32FromMemLE(
|
||||
((const Byte *)altCoderInfo.Properties + 1));
|
||||
((const Byte *)coderInfo.Properties + 1));
|
||||
methodsString += GetStringForSizeValue(dicSize);
|
||||
}
|
||||
}
|
||||
else if (altCoderInfo.MethodID == k_AES)
|
||||
else if (coderInfo.MethodID == k_AES)
|
||||
{
|
||||
if (altCoderInfo.Properties.GetCapacity() >= 1)
|
||||
if (coderInfo.Properties.GetCapacity() >= 1)
|
||||
{
|
||||
methodsString += L":";
|
||||
const Byte *data = (const Byte *)altCoderInfo.Properties;
|
||||
const Byte *data = (const Byte *)coderInfo.Properties;
|
||||
Byte firstByte = *data++;
|
||||
UInt32 numCyclesPower = firstByte & 0x3F;
|
||||
methodsString += ConvertUInt32ToString(numCyclesPower);
|
||||
@@ -361,7 +315,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
return S_OK;
|
||||
UInt32 saltSize = (firstByte >> 7) & 1;
|
||||
UInt32 ivSize = (firstByte >> 6) & 1;
|
||||
if (altCoderInfo.Properties.GetCapacity() >= 2)
|
||||
if (coderInfo.Properties.GetCapacity() >= 2)
|
||||
{
|
||||
Byte secondByte = *data++;
|
||||
saltSize += (secondByte >> 4);
|
||||
@@ -373,18 +327,18 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
}
|
||||
else
|
||||
{
|
||||
if (altCoderInfo.Properties.GetCapacity() > 0)
|
||||
if (coderInfo.Properties.GetCapacity() > 0)
|
||||
{
|
||||
methodsString += L":[";
|
||||
for (size_t bi = 0; bi < altCoderInfo.Properties.GetCapacity(); bi++)
|
||||
for (size_t bi = 0; bi < coderInfo.Properties.GetCapacity(); bi++)
|
||||
{
|
||||
if (bi > 5 && bi + 1 < altCoderInfo.Properties.GetCapacity())
|
||||
if (bi > 5 && bi + 1 < coderInfo.Properties.GetCapacity())
|
||||
{
|
||||
methodsString += L"..";
|
||||
break;
|
||||
}
|
||||
else
|
||||
methodsString += GetHex2(altCoderInfo.Properties[bi]);
|
||||
methodsString += GetHex2(coderInfo.Properties[bi]);
|
||||
}
|
||||
methodsString += L"]";
|
||||
}
|
||||
@@ -392,7 +346,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
}
|
||||
else
|
||||
{
|
||||
methodsString += altCoderInfo.MethodID.ConvertToString();
|
||||
methodsString += ConvertMethodIdToString(coderInfo.MethodID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -655,7 +609,9 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
#else
|
||||
CInArchive archive;
|
||||
RINOK(archive.Open(stream, maxCheckStartPosition));
|
||||
HRESULT result = archive.ReadDatabase(_database
|
||||
HRESULT result = archive.ReadDatabase(
|
||||
EXTERNAL_CODECS_VARS
|
||||
_database
|
||||
#ifndef _NO_CRYPTO
|
||||
, getTextPassword
|
||||
#endif
|
||||
@@ -733,8 +689,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
const CCoderInfo &coder = folder.Coders.Front();
|
||||
if (coder.NumInStreams != 1 || coder.NumOutStreams != 1)
|
||||
return S_FALSE;
|
||||
const CAltCoderInfo &altCoder = coder.AltCoders.Front();
|
||||
if (altCoder.MethodID.IDSize != 1 || altCoder.MethodID.ID[0] != 0)
|
||||
if (coder.MethodID != k_Copy)
|
||||
return S_FALSE;
|
||||
|
||||
pos += file.UnPackSize;
|
||||
@@ -791,4 +746,6 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
#endif
|
||||
#endif
|
||||
|
||||
IMPL_ISetCompressCodecsInfo
|
||||
|
||||
}}
|
||||
|
||||
@@ -3,19 +3,18 @@
|
||||
#ifndef __7Z_HANDLER_H
|
||||
#define __7Z_HANDLER_H
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../IArchive.h"
|
||||
#include "7zIn.h"
|
||||
|
||||
#include "7zCompressionMode.h"
|
||||
|
||||
#ifndef _SFX
|
||||
#include "7zMethods.h"
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
@@ -82,13 +81,12 @@ class CHandler:
|
||||
#ifndef EXTRACT_ONLY
|
||||
public IOutArchive,
|
||||
#endif
|
||||
PUBLIC_ISetCompressCodecsInfo
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
#if !defined(_7Z_VOL) && !defined(__7Z_SET_PROPERTIES) && defined(EXTRACT_ONLY)
|
||||
MY_UNKNOWN_IMP
|
||||
#else
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
#ifdef _7Z_VOL
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
|
||||
#endif
|
||||
@@ -98,9 +96,9 @@ public:
|
||||
#ifndef EXTRACT_ONLY
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
#endif
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
#endif
|
||||
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
@@ -144,6 +142,8 @@ public:
|
||||
HRESULT SetSolidSettings(const PROPVARIANT &value);
|
||||
#endif
|
||||
|
||||
DECL_ISetCompressCodecsInfo
|
||||
|
||||
CHandler();
|
||||
|
||||
private:
|
||||
@@ -155,6 +155,7 @@ private:
|
||||
NArchive::N7z::CArchiveDatabaseEx _database;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 _numThreads;
|
||||
#endif
|
||||
@@ -169,7 +170,6 @@ private:
|
||||
bool _solidExtension;
|
||||
|
||||
bool _compressHeaders;
|
||||
bool _compressHeadersFull;
|
||||
bool _encryptHeaders;
|
||||
|
||||
bool WriteModified;
|
||||
@@ -182,6 +182,7 @@ private:
|
||||
|
||||
bool _volumeMode;
|
||||
|
||||
DECL_EXTERNAL_CODECS_VARS
|
||||
|
||||
HRESULT SetParam(COneMethodInfo &oneMethodInfo, const UString &name, const UString &value);
|
||||
HRESULT SetParams(COneMethodInfo &oneMethodInfo, const UString &srcString);
|
||||
@@ -225,7 +226,6 @@ private:
|
||||
{
|
||||
_removeSfxBlock = false;
|
||||
_compressHeaders = true;
|
||||
_compressHeadersFull = true;
|
||||
_encryptHeaders = false;
|
||||
|
||||
WriteModified = true;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "7zHandler.h"
|
||||
#include "7zOut.h"
|
||||
#include "7zUpdate.h"
|
||||
#include "7zMethods.h"
|
||||
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
|
||||
@@ -22,47 +21,6 @@ using namespace NWindows;
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
static CMethodID k_LZMA2 = { { 0x3, 0x1, 0x2 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
static CMethodID k_PPMD = { { 0x3, 0x4, 0x1 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
static CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ2
|
||||
static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
static CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE
|
||||
#ifndef COMPRESS_DEFLATE_ENCODER
|
||||
#define COMPRESS_DEFLATE_ENCODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_ENCODER
|
||||
static CMethodID k_Deflate = { { 0x4, 0x1, 0x8 }, 3 };
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2
|
||||
#ifndef COMPRESS_BZIP2_ENCODER
|
||||
#define COMPRESS_BZIP2_ENCODER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_ENCODER
|
||||
static CMethodID k_BZip2 = { { 0x4, 0x2, 0x2 }, 3 };
|
||||
#endif
|
||||
|
||||
const wchar_t *kCopyMethod = L"Copy";
|
||||
const wchar_t *kLZMAMethodName = L"LZMA";
|
||||
const wchar_t *kLZMA2MethodName = L"LZMA2";
|
||||
@@ -79,8 +37,8 @@ static const UInt32 kLzmaAlgorithmX5 = 1;
|
||||
|
||||
static const UInt32 kLzmaDicSizeX1 = 1 << 16;
|
||||
static const UInt32 kLzmaDicSizeX3 = 1 << 20;
|
||||
static const UInt32 kLzmaDicSizeX5 = 1 << 22;
|
||||
static const UInt32 kLzmaDicSizeX7 = 1 << 24;
|
||||
static const UInt32 kLzmaDicSizeX5 = 1 << 24;
|
||||
static const UInt32 kLzmaDicSizeX7 = 1 << 25;
|
||||
static const UInt32 kLzmaDicSizeX9 = 1 << 26;
|
||||
|
||||
static const UInt32 kLzmaFastBytesX1 = 32;
|
||||
@@ -240,8 +198,6 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
);
|
||||
RINOK(res);
|
||||
methodMode.Binds = _binds;
|
||||
if (_compressHeadersFull)
|
||||
_compressHeaders = true;
|
||||
|
||||
if (_compressHeaders)
|
||||
{
|
||||
@@ -308,15 +264,6 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifndef EXCLUDE_COM
|
||||
/*
|
||||
CObjectVector<CMethodInfo2> methodInfoVector;
|
||||
if (!NRegistryInfo::EnumerateAllMethods(methodInfoVector))
|
||||
return E_FAIL;
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
UInt32 level = _level;
|
||||
|
||||
if (methodsInfo.IsEmpty())
|
||||
@@ -418,93 +365,11 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
|
||||
|
||||
CMethodFull methodFull;
|
||||
methodFull.NumInStreams = 1;
|
||||
methodFull.NumOutStreams = 1;
|
||||
|
||||
bool defined = false;
|
||||
|
||||
#ifdef COMPRESS_LZMA
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"LZMA") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_LZMA;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_PPMD
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"PPMD") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_PPMD;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ_X86
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"BCJ") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_BCJ_X86;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BCJ2
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"BCJ2") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_BCJ2;
|
||||
methodFull.NumInStreams = 4;
|
||||
methodFull.NumOutStreams = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_DEFLATE_ENCODER
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"Deflate") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_Deflate;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_BZIP2_ENCODER
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"BZip2") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_BZip2;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_COPY
|
||||
if (oneMethodInfo.MethodName.CompareNoCase(L"Copy") == 0)
|
||||
{
|
||||
defined = true;
|
||||
methodFull.MethodID = k_Copy;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
|
||||
if (!defined)
|
||||
{
|
||||
CMethodInfo2 methodInfo;
|
||||
if (!GetMethodInfo(oneMethodInfo.MethodName, methodInfo))
|
||||
return E_INVALIDARG;
|
||||
if (!methodInfo.EncoderIsAssigned)
|
||||
return E_INVALIDARG;
|
||||
|
||||
methodFull.MethodID = methodInfo.MethodID;
|
||||
methodFull.NumInStreams = methodInfo.NumInStreams;
|
||||
methodFull.NumOutStreams = methodInfo.NumOutStreams;
|
||||
|
||||
methodFull.EncoderClassID = methodInfo.Encoder;
|
||||
methodFull.FilePath = methodInfo.FilePath;
|
||||
defined = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (!defined)
|
||||
if (!FindMethod(
|
||||
EXTERNAL_CODECS_VARS
|
||||
oneMethodInfo.MethodName, methodFull.MethodID, methodFull.NumInStreams, methodFull.NumOutStreams))
|
||||
return E_INVALIDARG;
|
||||
|
||||
methodFull.CoderProperties = oneMethodInfo.CoderProperties;
|
||||
methodMode.Methods.Add(methodFull);
|
||||
|
||||
@@ -707,17 +572,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
|
||||
RINOK(SetPassword(methodMode, updateCallback));
|
||||
|
||||
bool useAdditionalHeaderStreams = true;
|
||||
bool compressMainHeader = false;
|
||||
bool compressMainHeader = _compressHeaders; // check it
|
||||
|
||||
if (_compressHeadersFull)
|
||||
{
|
||||
useAdditionalHeaderStreams = false;
|
||||
compressMainHeader = true;
|
||||
}
|
||||
if (methodMode.PasswordIsDefined)
|
||||
{
|
||||
useAdditionalHeaderStreams = false;
|
||||
compressMainHeader = true;
|
||||
if(_encryptHeaders)
|
||||
RINOK(SetPassword(headerMethod, updateCallback));
|
||||
@@ -734,7 +592,6 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
options.UseFilters = _level != 0 && _autoFilter;
|
||||
options.MaxFilter = _level >= 8;
|
||||
|
||||
options.HeaderOptions.UseAdditionalHeaderStreams = useAdditionalHeaderStreams;
|
||||
options.HeaderOptions.CompressMainHeader = compressMainHeader;
|
||||
options.HeaderOptions.WriteModified = WriteModified;
|
||||
options.HeaderOptions.WriteCreated = WriteCreated;
|
||||
@@ -746,6 +603,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
options.RemoveSfxBlock = _removeSfxBlock;
|
||||
options.VolumeMode = _volumeMode;
|
||||
return Update(
|
||||
EXTERNAL_CODECS_VARS
|
||||
#ifdef _7Z_VOL
|
||||
volume ? volume->Stream: 0,
|
||||
volume ? database: 0,
|
||||
@@ -1050,7 +908,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
}
|
||||
else if (name.CompareNoCase(L"HCF") == 0)
|
||||
{
|
||||
RINOK(SetBoolProperty(_compressHeadersFull, value));
|
||||
bool compressHeadersFull = true;
|
||||
RINOK(SetBoolProperty(compressHeadersFull, value));
|
||||
if (!compressHeadersFull)
|
||||
return E_INVALIDARG;
|
||||
continue;
|
||||
}
|
||||
else if (name.CompareNoCase(L"HE") == 0)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef __7Z_HEADER_H
|
||||
#define __7Z_HEADER_H
|
||||
|
||||
#include "7zMethodID.h"
|
||||
#include "../../../Common/Types.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "7zIn.h"
|
||||
#include "7zMethods.h"
|
||||
#include "7zDecode.h"
|
||||
#include "../../Common/StreamObjects.h"
|
||||
#include "../../Common/StreamUtils.h"
|
||||
#include "../../../Common/CRC.h"
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/7zCrc.h"
|
||||
}
|
||||
|
||||
// define FORMAT_7Z_RECOVERY if you want to recover multivolume archives with empty StartHeader
|
||||
// #define FORMAT_7Z_RECOVERY
|
||||
@@ -99,7 +101,7 @@ HRESULT CInArchive::SafeReadDirectByte(Byte &b)
|
||||
return SafeReadDirect(&b, 1);
|
||||
}
|
||||
|
||||
HRESULT CInArchive::SafeReadDirectUInt32(UInt32 &value)
|
||||
HRESULT CInArchive::SafeReadDirectUInt32(UInt32 &value, UInt32 &crc)
|
||||
{
|
||||
value = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
@@ -107,11 +109,12 @@ HRESULT CInArchive::SafeReadDirectUInt32(UInt32 &value)
|
||||
Byte b;
|
||||
RINOK(SafeReadDirectByte(b));
|
||||
value |= (UInt32(b) << (8 * i));
|
||||
crc = CRC_UPDATE_BYTE(crc, b);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::SafeReadDirectUInt64(UInt64 &value)
|
||||
HRESULT CInArchive::SafeReadDirectUInt64(UInt64 &value, UInt32 &crc)
|
||||
{
|
||||
value = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
@@ -119,6 +122,7 @@ HRESULT CInArchive::SafeReadDirectUInt64(UInt64 &value)
|
||||
Byte b;
|
||||
RINOK(SafeReadDirectByte(b));
|
||||
value |= (UInt64(b) << (8 * i));
|
||||
crc = CRC_UPDATE_BYTE(crc, b);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -367,14 +371,19 @@ HRESULT CInArchive::GetNextFolderItem(CFolder &folder)
|
||||
folder.Coders.Add(CCoderInfo());
|
||||
CCoderInfo &coder = folder.Coders.Back();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
coder.AltCoders.Add(CAltCoderInfo());
|
||||
CAltCoderInfo &altCoder = coder.AltCoders.Back();
|
||||
Byte mainByte = 0;
|
||||
RINOK(ReadByte(mainByte));
|
||||
altCoder.MethodID.IDSize = (Byte)(mainByte & 0xF);
|
||||
RINOK(ReadBytes(altCoder.MethodID.ID, altCoder.MethodID.IDSize));
|
||||
int idSize = (mainByte & 0xF);
|
||||
BYTE longID[15];
|
||||
RINOK(ReadBytes(longID, idSize));
|
||||
if (idSize > 8)
|
||||
return S_FALSE;
|
||||
UInt64 id = 0;
|
||||
for (int j = 0; j < idSize; j++)
|
||||
id |= (UInt64)longID[idSize - 1 - j] << (8 * j);
|
||||
coder.MethodID = id;
|
||||
|
||||
if ((mainByte & 0x10) != 0)
|
||||
{
|
||||
RINOK(ReadNum(coder.NumInStreams));
|
||||
@@ -389,11 +398,11 @@ HRESULT CInArchive::GetNextFolderItem(CFolder &folder)
|
||||
{
|
||||
CNum propertiesSize = 0;
|
||||
RINOK(ReadNum(propertiesSize));
|
||||
altCoder.Properties.SetCapacity((size_t)propertiesSize);
|
||||
RINOK(ReadBytes((Byte *)altCoder.Properties, (size_t)propertiesSize));
|
||||
coder.Properties.SetCapacity((size_t)propertiesSize);
|
||||
RINOK(ReadBytes((Byte *)coder.Properties, (size_t)propertiesSize));
|
||||
}
|
||||
if ((mainByte & 0x80) == 0)
|
||||
break;
|
||||
if ((mainByte & 0x80) != 0)
|
||||
return S_FALSE;
|
||||
}
|
||||
numInStreams += coder.NumInStreams;
|
||||
numOutStreams += coder.NumOutStreams;
|
||||
@@ -826,7 +835,9 @@ HRESULT CInArchive::ReadTime(const CObjectVector<CByteBuffer> &dataVector,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadAndDecodePackedStreams(UInt64 baseOffset,
|
||||
HRESULT CInArchive::ReadAndDecodePackedStreams(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 baseOffset,
|
||||
UInt64 &dataOffset, CObjectVector<CByteBuffer> &dataVector
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getTextPassword
|
||||
@@ -881,7 +892,9 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(UInt64 baseOffset,
|
||||
CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
|
||||
outStreamSpec->Init(data, (size_t)unPackSize);
|
||||
|
||||
HRESULT result = decoder.Decode(_stream, dataStartPos,
|
||||
HRESULT result = decoder.Decode(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
_stream, dataStartPos,
|
||||
&packSizes[packIndex], folder, outStream, NULL
|
||||
#ifndef _NO_CRYPTO
|
||||
, getTextPassword
|
||||
@@ -893,7 +906,7 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(UInt64 baseOffset,
|
||||
RINOK(result);
|
||||
|
||||
if (folder.UnPackCRCDefined)
|
||||
if (!CCRC::VerifyDigest(folder.UnPackCRC, data, (UInt32)unPackSize))
|
||||
if (CrcCalc(data, (UInt32)unPackSize) != folder.UnPackCRC)
|
||||
throw CInArchiveException(CInArchiveException::kIncorrectHeader);
|
||||
for (int j = 0; j < folder.PackStreams.Size(); j++)
|
||||
dataStartPos += packSizes[packIndex++];
|
||||
@@ -901,7 +914,9 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(UInt64 baseOffset,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadHeader(CArchiveDatabaseEx &database
|
||||
HRESULT CInArchive::ReadHeader(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CArchiveDatabaseEx &database
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
@@ -921,6 +936,7 @@ HRESULT CInArchive::ReadHeader(CArchiveDatabaseEx &database
|
||||
if (type == NID::kAdditionalStreamsInfo)
|
||||
{
|
||||
HRESULT result = ReadAndDecodePackedStreams(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
database.ArchiveInfo.StartPositionAfterHeader,
|
||||
database.ArchiveInfo.DataStartPosition2,
|
||||
dataVector
|
||||
@@ -1192,7 +1208,9 @@ void CArchiveDatabaseEx::FillFolderStartFileIndex()
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
HRESULT CInArchive::ReadDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CArchiveDatabaseEx &database
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
@@ -1219,11 +1237,12 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
UInt64 nextHeaderOffset;
|
||||
UInt64 nextHeaderSize;
|
||||
UInt32 nextHeaderCRC;
|
||||
CCRC crc;
|
||||
RINOK(SafeReadDirectUInt32(crcFromArchive));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderOffset));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderSize));
|
||||
RINOK(SafeReadDirectUInt32(nextHeaderCRC));
|
||||
UInt32 crc = CRC_INIT_VAL;
|
||||
UInt32 temp;
|
||||
RINOK(SafeReadDirectUInt32(crcFromArchive, temp));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderOffset, crc));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderSize, crc));
|
||||
RINOK(SafeReadDirectUInt32(nextHeaderCRC, crc));
|
||||
|
||||
#ifdef FORMAT_7Z_RECOVERY
|
||||
if (crcFromArchive == 0 && nextHeaderOffset == 0 && nextHeaderSize == 0 && nextHeaderCRC == 0)
|
||||
@@ -1254,10 +1273,6 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
}
|
||||
#endif
|
||||
|
||||
crc.UpdateUInt64(nextHeaderOffset);
|
||||
crc.UpdateUInt64(nextHeaderSize);
|
||||
crc.UpdateUInt32(nextHeaderCRC);
|
||||
|
||||
#ifdef FORMAT_7Z_RECOVERY
|
||||
crcFromArchive = crc.GetDigest();
|
||||
#endif
|
||||
@@ -1278,7 +1293,7 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
{
|
||||
database.ArchiveInfo.StartPositionAfterHeader = _position;
|
||||
}
|
||||
if (crc.GetDigest() != crcFromArchive)
|
||||
if (CRC_GET_DIGEST(crc) != crcFromArchive)
|
||||
throw CInArchiveException(CInArchiveException::kIncorrectHeader);
|
||||
|
||||
if (nextHeaderSize == 0)
|
||||
@@ -1292,7 +1307,7 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
CByteBuffer buffer2;
|
||||
buffer2.SetCapacity((size_t)nextHeaderSize);
|
||||
RINOK(SafeReadDirect(buffer2, (UInt32)nextHeaderSize));
|
||||
if (!CCRC::VerifyDigest(nextHeaderCRC, buffer2, (UInt32)nextHeaderSize))
|
||||
if (CrcCalc(buffer2, (UInt32)nextHeaderSize) != nextHeaderCRC)
|
||||
throw CInArchiveException(CInArchiveException::kIncorrectHeader);
|
||||
|
||||
CStreamSwitch streamSwitch;
|
||||
@@ -1309,6 +1324,7 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
if (type != NID::kEncodedHeader)
|
||||
throw CInArchiveException(CInArchiveException::kIncorrectHeader);
|
||||
HRESULT result = ReadAndDecodePackedStreams(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
database.ArchiveInfo.StartPositionAfterHeader,
|
||||
database.ArchiveInfo.DataStartPosition2,
|
||||
dataVector
|
||||
@@ -1325,7 +1341,9 @@ HRESULT CInArchive::ReadDatabase(CArchiveDatabaseEx &database
|
||||
streamSwitch.Set(this, dataVector.Front());
|
||||
}
|
||||
|
||||
return ReadHeader(database
|
||||
return ReadHeader(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
database
|
||||
#ifndef _NO_CRYPTO
|
||||
, getTextPassword
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
#include "../../IStream.h"
|
||||
#include "../../IPassword.h"
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../Common/InBuffer.h"
|
||||
|
||||
@@ -95,11 +98,9 @@ struct CArchiveDatabaseEx: public CArchiveDatabase
|
||||
UInt64 GetFilePackSize(CNum fileIndex) const
|
||||
{
|
||||
CNum folderIndex = FileIndexToFolderIndexMap[fileIndex];
|
||||
if (folderIndex >= 0)
|
||||
{
|
||||
if (folderIndex != kNumNoIndex)
|
||||
if (FolderStartFileIndex[folderIndex] == fileIndex)
|
||||
return GetFolderFullPackSize(folderIndex);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@@ -182,8 +183,8 @@ private:
|
||||
HRESULT ReadDirect(void *data, UInt32 size, UInt32 *processedSize);
|
||||
HRESULT SafeReadDirect(void *data, UInt32 size);
|
||||
HRESULT SafeReadDirectByte(Byte &b);
|
||||
HRESULT SafeReadDirectUInt32(UInt32 &value);
|
||||
HRESULT SafeReadDirectUInt64(UInt64 &value);
|
||||
HRESULT SafeReadDirectUInt32(UInt32 &value, UInt32 &crc);
|
||||
HRESULT SafeReadDirectUInt64(UInt64 &value, UInt32 &crc);
|
||||
|
||||
HRESULT ReadBytes(void *data, size_t size)
|
||||
{
|
||||
@@ -261,13 +262,17 @@ private:
|
||||
HRESULT ReadBoolVector2(int numItems, CBoolVector &v);
|
||||
HRESULT ReadTime(const CObjectVector<CByteBuffer> &dataVector,
|
||||
CObjectVector<CFileItem> &files, UInt64 type);
|
||||
HRESULT ReadAndDecodePackedStreams(UInt64 baseOffset, UInt64 &dataOffset,
|
||||
HRESULT ReadAndDecodePackedStreams(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 baseOffset, UInt64 &dataOffset,
|
||||
CObjectVector<CByteBuffer> &dataVector
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
);
|
||||
HRESULT ReadHeader(CArchiveDatabaseEx &database
|
||||
HRESULT ReadHeader(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CArchiveDatabaseEx &database
|
||||
#ifndef _NO_CRYPTO
|
||||
,ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
@@ -276,7 +281,9 @@ public:
|
||||
HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit); // S_FALSE means is not archive
|
||||
void Close();
|
||||
|
||||
HRESULT ReadDatabase(CArchiveDatabaseEx &database
|
||||
HRESULT ReadDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CArchiveDatabaseEx &database
|
||||
#ifndef _NO_CRYPTO
|
||||
,ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
|
||||
@@ -4,27 +4,23 @@
|
||||
#define __7Z_ITEM_H
|
||||
|
||||
#include "../../../Common/Buffer.h"
|
||||
#include "7zMethodID.h"
|
||||
#include "../../../Common/String.h"
|
||||
#include "../../Common/MethodID.h"
|
||||
#include "7zHeader.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
struct CAltCoderInfo
|
||||
{
|
||||
CMethodID MethodID;
|
||||
CByteBuffer Properties;
|
||||
};
|
||||
|
||||
typedef UInt32 CNum;
|
||||
const CNum kNumMax = 0x7FFFFFFF;
|
||||
const CNum kNumNoIndex = 0xFFFFFFFF;
|
||||
|
||||
struct CCoderInfo
|
||||
{
|
||||
CMethodId MethodID;
|
||||
CByteBuffer Properties;
|
||||
CNum NumInStreams;
|
||||
CNum NumOutStreams;
|
||||
CObjectVector<CAltCoderInfo> AltCoders;
|
||||
bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); }
|
||||
};
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
// 7zMethodID.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "7zMethodID.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
static wchar_t GetHex(Byte value)
|
||||
{
|
||||
return (wchar_t)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
|
||||
}
|
||||
|
||||
static bool HexCharToInt(wchar_t value, Byte &result)
|
||||
{
|
||||
if (value >= '0' && value <= '9')
|
||||
result = (Byte)(value - '0');
|
||||
else if (value >= 'a' && value <= 'f')
|
||||
result = (Byte)(10 + value - 'a');
|
||||
else if (value >= 'A' && value <= 'F')
|
||||
result = (Byte)(10 + value - 'A');
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool TwoHexCharsToInt(wchar_t valueHigh, wchar_t valueLow, Byte &result)
|
||||
{
|
||||
Byte resultHigh, resultLow;
|
||||
if (!HexCharToInt(valueHigh, resultHigh))
|
||||
return false;
|
||||
if (!HexCharToInt(valueLow, resultLow))
|
||||
return false;
|
||||
result = (Byte)((resultHigh << 4) + resultLow);
|
||||
return true;
|
||||
}
|
||||
|
||||
UString CMethodID::ConvertToString() const
|
||||
{
|
||||
UString result;
|
||||
for (int i = 0; i < IDSize; i++)
|
||||
{
|
||||
Byte b = ID[i];
|
||||
result += GetHex((Byte)(b >> 4));
|
||||
result += GetHex((Byte)(b & 0xF));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CMethodID::ConvertFromString(const UString &srcString)
|
||||
{
|
||||
int length = srcString.Length();
|
||||
if ((length & 1) != 0 || (length >> 1) > kMethodIDSize)
|
||||
return false;
|
||||
IDSize = (Byte)(length / 2);
|
||||
UInt32 i;
|
||||
for(i = 0; i < IDSize; i++)
|
||||
if (!TwoHexCharsToInt(srcString[i * 2], srcString[i * 2 + 1], ID[i]))
|
||||
return false;
|
||||
for(; i < kMethodIDSize; i++)
|
||||
ID[i] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const CMethodID &a1, const CMethodID &a2)
|
||||
{
|
||||
if (a1.IDSize != a2.IDSize)
|
||||
return false;
|
||||
for (UInt32 i = 0; i < a1.IDSize; i++)
|
||||
if (a1.ID[i] != a2.ID[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -1,29 +0,0 @@
|
||||
// 7zMethodID.h
|
||||
|
||||
#ifndef __7Z_METHOD_ID_H
|
||||
#define __7Z_METHOD_ID_H
|
||||
|
||||
#include "../../../Common/String.h"
|
||||
#include "../../../Common/Types.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
const int kMethodIDSize = 15;
|
||||
|
||||
struct CMethodID
|
||||
{
|
||||
Byte ID[kMethodIDSize];
|
||||
Byte IDSize;
|
||||
UString ConvertToString() const;
|
||||
bool ConvertFromString(const UString &srcString);
|
||||
};
|
||||
|
||||
bool operator==(const CMethodID &a1, const CMethodID &a2);
|
||||
|
||||
inline bool operator!=(const CMethodID &a1, const CMethodID &a2)
|
||||
{ return !(a1 == a2); }
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,174 +0,0 @@
|
||||
// 7zMethods.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "7zMethods.h"
|
||||
|
||||
#include "../../../Windows/FileFind.h"
|
||||
#include "../../../Windows/DLL.h"
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
|
||||
#include "../../ICoder.h"
|
||||
#include "../Common/CodecsPath.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
static CObjectVector<CMethodInfo2> g_Methods;
|
||||
static bool g_Loaded = false;
|
||||
|
||||
typedef UInt32 (WINAPI *GetNumberOfMethodsFunc)(UInt32 *numMethods);
|
||||
|
||||
typedef UInt32 (WINAPI *GetMethodPropertyFunc)(
|
||||
UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||
|
||||
static void Load(const CSysString &folderPrefix)
|
||||
{
|
||||
NFile::NFind::CEnumerator enumerator(folderPrefix + CSysString(TEXT("*")));
|
||||
NFile::NFind::CFileInfo fileInfo;
|
||||
while (enumerator.Next(fileInfo))
|
||||
{
|
||||
if (fileInfo.IsDirectory())
|
||||
continue;
|
||||
CSysString filePath = folderPrefix + fileInfo.Name;
|
||||
{
|
||||
NDLL::CLibrary library;
|
||||
if (!library.LoadEx(filePath, LOAD_LIBRARY_AS_DATAFILE))
|
||||
continue;
|
||||
}
|
||||
NDLL::CLibrary library;
|
||||
if (!library.Load(filePath))
|
||||
continue;
|
||||
GetMethodPropertyFunc getMethodProperty = (GetMethodPropertyFunc)
|
||||
library.GetProcAddress("GetMethodProperty");
|
||||
if (getMethodProperty == NULL)
|
||||
continue;
|
||||
|
||||
UInt32 numMethods = 1;
|
||||
GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)
|
||||
library.GetProcAddress("GetNumberOfMethods");
|
||||
if (getNumberOfMethodsFunc != NULL)
|
||||
if (getNumberOfMethodsFunc(&numMethods) != S_OK)
|
||||
continue;
|
||||
|
||||
for(UInt32 i = 0; i < numMethods; i++)
|
||||
{
|
||||
CMethodInfo2 info;
|
||||
info.FilePath = filePath;
|
||||
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
if (getMethodProperty(i, NMethodPropID::kID, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt != VT_BSTR)
|
||||
continue;
|
||||
info.MethodID.IDSize = (Byte)SysStringByteLen(propVariant.bstrVal);
|
||||
memmove(info.MethodID.ID, propVariant.bstrVal, info.MethodID.IDSize);
|
||||
propVariant.Clear();
|
||||
|
||||
if (getMethodProperty(i, NMethodPropID::kName, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
{
|
||||
}
|
||||
else if (propVariant.vt == VT_BSTR)
|
||||
info.Name = propVariant.bstrVal;
|
||||
else
|
||||
continue;
|
||||
propVariant.Clear();
|
||||
|
||||
if (getMethodProperty (i, NMethodPropID::kEncoder, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
info.EncoderIsAssigned = false;
|
||||
else if (propVariant.vt == VT_BSTR)
|
||||
{
|
||||
info.EncoderIsAssigned = true;
|
||||
info.Encoder = *(const GUID *)propVariant.bstrVal;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
propVariant.Clear();
|
||||
|
||||
if (getMethodProperty (i, NMethodPropID::kDecoder, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
info.DecoderIsAssigned = false;
|
||||
else if (propVariant.vt == VT_BSTR)
|
||||
{
|
||||
info.DecoderIsAssigned = true;
|
||||
info.Decoder = *(const GUID *)propVariant.bstrVal;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
propVariant.Clear();
|
||||
|
||||
if (getMethodProperty (i, NMethodPropID::kInStreams, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
info.NumInStreams = 1;
|
||||
else if (propVariant.vt == VT_UI4)
|
||||
info.NumInStreams = propVariant.ulVal;
|
||||
else
|
||||
continue;
|
||||
propVariant.Clear();
|
||||
|
||||
if (getMethodProperty (i, NMethodPropID::kOutStreams, &propVariant) != S_OK)
|
||||
continue;
|
||||
if (propVariant.vt == VT_EMPTY)
|
||||
info.NumOutStreams = 1;
|
||||
else if (propVariant.vt == VT_UI4)
|
||||
info.NumOutStreams = propVariant.ulVal;
|
||||
else
|
||||
continue;
|
||||
propVariant.Clear();
|
||||
|
||||
g_Methods.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
|
||||
void LoadMethodMap()
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
|
||||
if (g_Loaded)
|
||||
return;
|
||||
g_Loaded = true;
|
||||
Load(GetCodecsFolderPrefix());
|
||||
}
|
||||
|
||||
bool GetMethodInfo(const CMethodID &methodID, CMethodInfo &methodInfo)
|
||||
{
|
||||
for(int i = 0; i < g_Methods.Size(); i++)
|
||||
{
|
||||
const CMethodInfo2 &method = g_Methods[i];
|
||||
if (method.MethodID == methodID)
|
||||
{
|
||||
methodInfo = (CMethodInfo)method;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetMethodInfo(const UString &name, CMethodInfo2 &methodInfo)
|
||||
{
|
||||
for(int i = 0; i < g_Methods.Size(); i++)
|
||||
{
|
||||
const CMethodInfo2 &method = g_Methods[i];
|
||||
if (method.Name.CompareNoCase(name) == 0)
|
||||
{
|
||||
methodInfo = method;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// 7zMethods.h
|
||||
|
||||
#ifndef __7Z_METHODS_H
|
||||
#define __7Z_METHODS_H
|
||||
|
||||
#include "7zMethodID.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
struct CMethodInfo
|
||||
{
|
||||
UString Name;
|
||||
bool EncoderIsAssigned;
|
||||
bool DecoderIsAssigned;
|
||||
UInt32 NumInStreams;
|
||||
UInt32 NumOutStreams;
|
||||
CLSID Encoder;
|
||||
CLSID Decoder;
|
||||
// UString Description;
|
||||
CSysString FilePath;
|
||||
};
|
||||
|
||||
struct CMethodInfo2: public CMethodInfo
|
||||
{
|
||||
CMethodID MethodID;
|
||||
};
|
||||
|
||||
void LoadMethodMap();
|
||||
bool GetMethodInfo(const CMethodID &methodID, CMethodInfo &methodInfo);
|
||||
bool GetMethodInfo(const UString &name, CMethodInfo2 &methodInfo);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
+73
-183
@@ -7,6 +7,11 @@
|
||||
|
||||
#include "7zOut.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/7zCrc.h"
|
||||
}
|
||||
|
||||
static HRESULT WriteBytes(ISequentialOutStream *stream, const void *data, size_t size)
|
||||
{
|
||||
while (size > 0)
|
||||
@@ -30,6 +35,20 @@ HRESULT COutArchive::WriteDirect(const void *data, UInt32 size)
|
||||
return ::WriteBytes(SeqStream, data, size);
|
||||
}
|
||||
|
||||
UInt32 CrcUpdateUInt32(UInt32 crc, UInt32 value)
|
||||
{
|
||||
for (int i = 0; i < 4; i++, value >>= 8)
|
||||
crc = CRC_UPDATE_BYTE(crc, (Byte)value);
|
||||
return crc;
|
||||
}
|
||||
|
||||
UInt32 CrcUpdateUInt64(UInt32 crc, UInt64 value)
|
||||
{
|
||||
for (int i = 0; i < 8; i++, value >>= 8)
|
||||
crc = CRC_UPDATE_BYTE(crc, (Byte)value);
|
||||
return crc;
|
||||
}
|
||||
|
||||
HRESULT COutArchive::WriteDirectUInt32(UInt32 value)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
@@ -71,11 +90,11 @@ HRESULT COutArchive::WriteFinishSignature()
|
||||
|
||||
HRESULT COutArchive::WriteStartHeader(const CStartHeader &h)
|
||||
{
|
||||
CCRC crc;
|
||||
crc.UpdateUInt64(h.NextHeaderOffset);
|
||||
crc.UpdateUInt64(h.NextHeaderSize);
|
||||
crc.UpdateUInt32(h.NextHeaderCRC);
|
||||
RINOK(WriteDirectUInt32(crc.GetDigest()));
|
||||
UInt32 crc = CRC_INIT_VAL;
|
||||
crc = CrcUpdateUInt64(crc, h.NextHeaderOffset);
|
||||
crc = CrcUpdateUInt64(crc, h.NextHeaderSize);
|
||||
crc = CrcUpdateUInt32(crc, h.NextHeaderCRC);
|
||||
RINOK(WriteDirectUInt32(CRC_GET_DIGEST(crc)));
|
||||
RINOK(WriteDirectUInt64(h.NextHeaderOffset));
|
||||
RINOK(WriteDirectUInt64(h.NextHeaderSize));
|
||||
return WriteDirectUInt32(h.NextHeaderCRC);
|
||||
@@ -161,7 +180,7 @@ HRESULT COutArchive::WriteBytes(const void *data, size_t size)
|
||||
_dynamicBuffer.Write(data, size);
|
||||
else
|
||||
_outByte.WriteBytes(data, size);
|
||||
_crc.Update(data, size);
|
||||
_crc = CrcUpdate(_crc, data, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -217,6 +236,7 @@ HRESULT COutArchive::WriteNumber(UInt64 value)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
static UInt32 GetBigNumberSize(UInt64 value)
|
||||
{
|
||||
int i;
|
||||
@@ -226,7 +246,6 @@ static UInt32 GetBigNumberSize(UInt64 value)
|
||||
return 1 + i;
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
UInt32 COutArchive::GetVolHeadersSize(UInt64 dataSize, int nameLength, bool props)
|
||||
{
|
||||
UInt32 result = GetBigNumberSize(dataSize) * 2 + 41;
|
||||
@@ -268,19 +287,24 @@ HRESULT COutArchive::WriteFolder(const CFolder &folder)
|
||||
for (i = 0; i < folder.Coders.Size(); i++)
|
||||
{
|
||||
const CCoderInfo &coder = folder.Coders[i];
|
||||
for (int j = 0; j < coder.AltCoders.Size(); j++)
|
||||
{
|
||||
const CAltCoderInfo &altCoder = coder.AltCoders[j];
|
||||
size_t propertiesSize = altCoder.Properties.GetCapacity();
|
||||
size_t propertiesSize = coder.Properties.GetCapacity();
|
||||
|
||||
UInt64 id = coder.MethodID;
|
||||
int idSize;
|
||||
for (idSize = 1; idSize < sizeof(id); idSize++)
|
||||
if ((id >> (8 * idSize)) == 0)
|
||||
break;
|
||||
BYTE longID[15];
|
||||
for (int t = idSize - 1; t >= 0 ; t--, id >>= 8)
|
||||
longID[t] = (Byte)(id & 0xFF);
|
||||
Byte b;
|
||||
b = (Byte)(altCoder.MethodID.IDSize & 0xF);
|
||||
b = (Byte)(idSize & 0xF);
|
||||
bool isComplex = !coder.IsSimpleCoder();
|
||||
b |= (isComplex ? 0x10 : 0);
|
||||
b |= ((propertiesSize != 0) ? 0x20 : 0 );
|
||||
b |= ((j == coder.AltCoders.Size() - 1) ? 0 : 0x80 );
|
||||
RINOK(WriteByte(b));
|
||||
RINOK(WriteBytes(altCoder.MethodID.ID, altCoder.MethodID.IDSize));
|
||||
RINOK(WriteBytes(longID, idSize));
|
||||
if (isComplex)
|
||||
{
|
||||
RINOK(WriteNumber(coder.NumInStreams));
|
||||
@@ -289,7 +313,7 @@ HRESULT COutArchive::WriteFolder(const CFolder &folder)
|
||||
if (propertiesSize == 0)
|
||||
continue;
|
||||
RINOK(WriteNumber(propertiesSize));
|
||||
RINOK(WriteBytes(altCoder.Properties, propertiesSize));
|
||||
RINOK(WriteBytes(coder.Properties, propertiesSize));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < folder.BindPairs.Size(); i++)
|
||||
@@ -380,10 +404,7 @@ HRESULT COutArchive::WritePackInfo(
|
||||
return WriteByte(NID::kEnd);
|
||||
}
|
||||
|
||||
HRESULT COutArchive::WriteUnPackInfo(
|
||||
bool externalFolders,
|
||||
CNum externalFoldersStreamIndex,
|
||||
const CObjectVector<CFolder> &folders)
|
||||
HRESULT COutArchive::WriteUnPackInfo(const CObjectVector<CFolder> &folders)
|
||||
{
|
||||
if (folders.IsEmpty())
|
||||
return S_OK;
|
||||
@@ -392,12 +413,6 @@ HRESULT COutArchive::WriteUnPackInfo(
|
||||
|
||||
RINOK(WriteByte(NID::kFolder));
|
||||
RINOK(WriteNumber(folders.Size()));
|
||||
if (externalFolders)
|
||||
{
|
||||
RINOK(WriteByte(1));
|
||||
RINOK(WriteNumber(externalFoldersStreamIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(WriteByte(0));
|
||||
for(int i = 0; i < folders.Size(); i++)
|
||||
@@ -484,8 +499,7 @@ HRESULT COutArchive::WriteSubStreamsInfo(
|
||||
}
|
||||
|
||||
HRESULT COutArchive::WriteTime(
|
||||
const CObjectVector<CFileItem> &files, Byte type,
|
||||
bool isExternal, CNum externalDataIndex)
|
||||
const CObjectVector<CFileItem> &files, Byte type)
|
||||
{
|
||||
/////////////////////////////////////////////////
|
||||
// CreationTime
|
||||
@@ -520,9 +534,6 @@ HRESULT COutArchive::WriteTime(
|
||||
return S_OK;
|
||||
RINOK(WriteByte(type));
|
||||
size_t dataSize = 1 + 1;
|
||||
if (isExternal)
|
||||
dataSize += GetBigNumberSize(externalDataIndex);
|
||||
else
|
||||
dataSize += files.Size() * 8;
|
||||
if (allDefined)
|
||||
{
|
||||
@@ -535,12 +546,6 @@ HRESULT COutArchive::WriteTime(
|
||||
WriteByte(0);
|
||||
RINOK(WriteBoolVector(boolVector));
|
||||
}
|
||||
if (isExternal)
|
||||
{
|
||||
RINOK(WriteByte(1));
|
||||
RINOK(WriteNumber(externalDataIndex));
|
||||
return S_OK;
|
||||
}
|
||||
RINOK(WriteByte(0));
|
||||
for(i = 0; i < files.Size(); i++)
|
||||
{
|
||||
@@ -569,7 +574,9 @@ HRESULT COutArchive::WriteTime(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT COutArchive::EncodeStream(CEncoder &encoder, const Byte *data, size_t dataSize,
|
||||
HRESULT COutArchive::EncodeStream(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CEncoder &encoder, const Byte *data, size_t dataSize,
|
||||
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders)
|
||||
{
|
||||
CSequentialInStreamImp *streamSpec = new CSequentialInStreamImp;
|
||||
@@ -577,17 +584,23 @@ HRESULT COutArchive::EncodeStream(CEncoder &encoder, const Byte *data, size_t da
|
||||
streamSpec->Init(data, dataSize);
|
||||
CFolder folderItem;
|
||||
folderItem.UnPackCRCDefined = true;
|
||||
folderItem.UnPackCRC = CCRC::CalculateDigest(data, dataSize);
|
||||
folderItem.UnPackCRC = CrcCalc(data, dataSize);
|
||||
UInt64 dataSize64 = dataSize;
|
||||
RINOK(encoder.Encode(stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL));
|
||||
RINOK(encoder.Encode(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL))
|
||||
folders.Add(folderItem);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT COutArchive::EncodeStream(CEncoder &encoder, const CByteBuffer &data,
|
||||
HRESULT COutArchive::EncodeStream(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CEncoder &encoder, const CByteBuffer &data,
|
||||
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders)
|
||||
{
|
||||
return EncodeStream(encoder, data, data.GetCapacity(), packSizes, folders);
|
||||
return EncodeStream(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
encoder, data, data.GetCapacity(), packSizes, folders);
|
||||
}
|
||||
|
||||
static void WriteUInt32ToBuffer(Byte *data, UInt32 value)
|
||||
@@ -609,62 +622,13 @@ static void WriteUInt64ToBuffer(Byte *data, UInt64 value)
|
||||
}
|
||||
|
||||
|
||||
HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
const CCompressionMethodMode *options,
|
||||
HRESULT COutArchive::WriteHeader(
|
||||
const CArchiveDatabase &database,
|
||||
const CHeaderOptions &headerOptions,
|
||||
UInt64 &headerOffset)
|
||||
{
|
||||
CObjectVector<CFolder> folders;
|
||||
|
||||
bool compressHeaders = (options != NULL);
|
||||
CMyAutoPtr<CEncoder> encoder;
|
||||
if (compressHeaders)
|
||||
{
|
||||
// it's for gcc2.95.2
|
||||
CMyAutoPtr<CEncoder> tmp(new CEncoder(*options));
|
||||
encoder = tmp;
|
||||
}
|
||||
|
||||
CRecordVector<UInt64> packSizes;
|
||||
|
||||
CNum dataIndex = 0;
|
||||
|
||||
//////////////////////////
|
||||
// Folders
|
||||
|
||||
CNum externalFoldersStreamIndex = 0;
|
||||
bool externalFolders = (compressHeaders && database.Folders.Size() > 8);
|
||||
if (externalFolders)
|
||||
{
|
||||
_mainMode = false;
|
||||
_countMode = true;
|
||||
_countSize = 0;
|
||||
int i;
|
||||
for(i = 0; i < database.Folders.Size(); i++)
|
||||
{
|
||||
RINOK(WriteFolder(database.Folders[i]));
|
||||
}
|
||||
|
||||
_countMode = false;
|
||||
|
||||
CByteBuffer foldersData;
|
||||
foldersData.SetCapacity(_countSize);
|
||||
_outByte2.Init(foldersData, foldersData.GetCapacity());
|
||||
|
||||
for(i = 0; i < database.Folders.Size(); i++)
|
||||
{
|
||||
RINOK(WriteFolder(database.Folders[i]));
|
||||
}
|
||||
|
||||
{
|
||||
externalFoldersStreamIndex = dataIndex++;
|
||||
RINOK(EncodeStream(*encoder, foldersData, packSizes, folders));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Names
|
||||
|
||||
@@ -679,8 +643,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
}
|
||||
|
||||
CByteBuffer namesData;
|
||||
CNum externalNamesStreamIndex = 0;
|
||||
bool externalNames = (compressHeaders && database.Files.Size() > 8);
|
||||
if (numDefinedNames > 0)
|
||||
{
|
||||
namesData.SetCapacity((size_t)namesDataSize);
|
||||
@@ -697,12 +659,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
namesData[pos++] = 0;
|
||||
namesData[pos++] = 0;
|
||||
}
|
||||
|
||||
if (externalNames)
|
||||
{
|
||||
externalNamesStreamIndex = dataIndex++;
|
||||
RINOK(EncodeStream(*encoder, namesData, packSizes, folders));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
@@ -719,8 +675,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
}
|
||||
|
||||
CByteBuffer attributesData;
|
||||
CNum externalAttributesStreamIndex = 0;
|
||||
bool externalAttributes = (compressHeaders && numDefinedAttributes > 8);
|
||||
if (numDefinedAttributes > 0)
|
||||
{
|
||||
attributesData.SetCapacity(numDefinedAttributes * 4);
|
||||
@@ -734,11 +688,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
pos += 4;
|
||||
}
|
||||
}
|
||||
if (externalAttributes)
|
||||
{
|
||||
externalAttributesStreamIndex = dataIndex++;
|
||||
RINOK(EncodeStream(*encoder, attributesData, packSizes, folders));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
@@ -755,8 +704,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
}
|
||||
|
||||
CByteBuffer startsData;
|
||||
CNum externalStartStreamIndex = 0;
|
||||
bool externalStarts = (compressHeaders && numDefinedStarts > 8);
|
||||
if (numDefinedStarts > 0)
|
||||
{
|
||||
startsData.SetCapacity(numDefinedStarts * 8);
|
||||
@@ -770,24 +717,16 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
pos += 8;
|
||||
}
|
||||
}
|
||||
if (externalStarts)
|
||||
{
|
||||
externalStartStreamIndex = dataIndex++;
|
||||
RINOK(EncodeStream(*encoder, startsData, packSizes, folders));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// Write Last Write Time
|
||||
CNum externalLastWriteTimeStreamIndex = 0;
|
||||
bool externalLastWriteTime = false;
|
||||
// /*
|
||||
CNum numDefinedLastWriteTimes = 0;
|
||||
for(i = 0; i < database.Files.Size(); i++)
|
||||
if (database.Files[i].IsLastWriteTimeDefined)
|
||||
numDefinedLastWriteTimes++;
|
||||
|
||||
externalLastWriteTime = (compressHeaders && numDefinedLastWriteTimes > 64);
|
||||
if (numDefinedLastWriteTimes > 0)
|
||||
{
|
||||
CByteBuffer lastWriteTimeData;
|
||||
@@ -804,11 +743,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
pos += 4;
|
||||
}
|
||||
}
|
||||
if (externalLastWriteTime)
|
||||
{
|
||||
externalLastWriteTimeStreamIndex = dataIndex++;
|
||||
RINOK(EncodeStream(*encoder, lastWriteTimeData, packSizes, folders));
|
||||
}
|
||||
}
|
||||
// */
|
||||
|
||||
@@ -816,34 +750,20 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
UInt64 packedSize = 0;
|
||||
for(i = 0; i < database.PackSizes.Size(); i++)
|
||||
packedSize += database.PackSizes[i];
|
||||
UInt64 headerPackSize = 0;
|
||||
for (i = 0; i < packSizes.Size(); i++)
|
||||
headerPackSize += packSizes[i];
|
||||
|
||||
headerOffset = packedSize + headerPackSize;
|
||||
headerOffset = packedSize;
|
||||
|
||||
_mainMode = true;
|
||||
|
||||
_outByte.SetStream(SeqStream);
|
||||
_outByte.Init();
|
||||
_crc.Init();
|
||||
_crc = CRC_INIT_VAL;
|
||||
|
||||
|
||||
RINOK(WriteByte(NID::kHeader));
|
||||
|
||||
// Archive Properties
|
||||
|
||||
if (folders.Size() > 0)
|
||||
{
|
||||
RINOK(WriteByte(NID::kAdditionalStreamsInfo));
|
||||
RINOK(WritePackInfo(packedSize, packSizes,
|
||||
CRecordVector<bool>(), CRecordVector<UInt32>()));
|
||||
RINOK(WriteUnPackInfo(false, 0, folders));
|
||||
RINOK(WriteByte(NID::kEnd));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
if (database.Folders.Size() > 0)
|
||||
{
|
||||
RINOK(WriteByte(NID::kMainStreamsInfo));
|
||||
@@ -851,7 +771,7 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
database.PackCRCsDefined,
|
||||
database.PackCRCs));
|
||||
|
||||
RINOK(WriteUnPackInfo(externalFolders, externalFoldersStreamIndex, database.Folders));
|
||||
RINOK(WriteUnPackInfo(database.Folders));
|
||||
|
||||
CRecordVector<UInt64> unPackSizes;
|
||||
CRecordVector<bool> digestsDefined;
|
||||
@@ -938,13 +858,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
{
|
||||
/////////////////////////////////////////////////
|
||||
RINOK(WriteByte(NID::kName));
|
||||
if (externalNames)
|
||||
{
|
||||
RINOK(WriteNumber(1 + GetBigNumberSize(externalNamesStreamIndex)));
|
||||
RINOK(WriteByte(1));
|
||||
RINOK(WriteNumber(externalNamesStreamIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(WriteNumber(1 + namesData.GetCapacity()));
|
||||
RINOK(WriteByte(0));
|
||||
@@ -955,17 +868,15 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
|
||||
if (headerOptions.WriteCreated)
|
||||
{
|
||||
RINOK(WriteTime(database.Files, NID::kCreationTime, false, 0));
|
||||
RINOK(WriteTime(database.Files, NID::kCreationTime));
|
||||
}
|
||||
if (headerOptions.WriteModified)
|
||||
{
|
||||
RINOK(WriteTime(database.Files, NID::kLastWriteTime,
|
||||
// false, 0));
|
||||
externalLastWriteTime, externalLastWriteTimeStreamIndex));
|
||||
RINOK(WriteTime(database.Files, NID::kLastWriteTime));
|
||||
}
|
||||
if (headerOptions.WriteAccessed)
|
||||
{
|
||||
RINOK(WriteTime(database.Files, NID::kLastAccessTime, false, 0));
|
||||
RINOK(WriteTime(database.Files, NID::kLastAccessTime));
|
||||
}
|
||||
|
||||
if (numDefinedAttributes > 0)
|
||||
@@ -974,9 +885,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
size_t size = 2;
|
||||
if (numDefinedAttributes != database.Files.Size())
|
||||
size += (attributesBoolVector.Size() + 7) / 8 + 1;
|
||||
if (externalAttributes)
|
||||
size += GetBigNumberSize(externalAttributesStreamIndex);
|
||||
else
|
||||
size += attributesData.GetCapacity();
|
||||
|
||||
RINOK(WriteNumber(size));
|
||||
@@ -990,12 +898,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
RINOK(WriteBoolVector(attributesBoolVector));
|
||||
}
|
||||
|
||||
if (externalAttributes)
|
||||
{
|
||||
RINOK(WriteByte(1));
|
||||
RINOK(WriteNumber(externalAttributesStreamIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(WriteByte(0));
|
||||
RINOK(WriteBytes(attributesData));
|
||||
@@ -1008,9 +910,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
size_t size = 2;
|
||||
if (numDefinedStarts != database.Files.Size())
|
||||
size += (startsBoolVector.Size() + 7) / 8 + 1;
|
||||
if (externalStarts)
|
||||
size += GetBigNumberSize(externalStartStreamIndex);
|
||||
else
|
||||
size += startsData.GetCapacity();
|
||||
|
||||
RINOK(WriteNumber(size));
|
||||
@@ -1024,12 +923,6 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
RINOK(WriteBoolVector(startsBoolVector));
|
||||
}
|
||||
|
||||
if (externalAttributes)
|
||||
{
|
||||
RINOK(WriteByte(1));
|
||||
RINOK(WriteNumber(externalStartStreamIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(WriteByte(0));
|
||||
RINOK(WriteBytes(startsData));
|
||||
@@ -1042,7 +935,9 @@ HRESULT COutArchive::WriteHeader(const CArchiveDatabase &database,
|
||||
return _outByte.Flush();
|
||||
}
|
||||
|
||||
HRESULT COutArchive::WriteDatabase(const CArchiveDatabase &database,
|
||||
HRESULT COutArchive::WriteDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const CArchiveDatabase &database,
|
||||
const CCompressionMethodMode *options,
|
||||
const CHeaderOptions &headerOptions)
|
||||
{
|
||||
@@ -1053,7 +948,7 @@ HRESULT COutArchive::WriteDatabase(const CArchiveDatabase &database,
|
||||
{
|
||||
headerSize = 0;
|
||||
headerOffset = 0;
|
||||
headerCRC = CCRC::CalculateDigest(0, 0);
|
||||
headerCRC = CrcCalc(0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1063,17 +958,10 @@ HRESULT COutArchive::WriteDatabase(const CArchiveDatabase &database,
|
||||
if (options != 0)
|
||||
if (options->IsEmpty())
|
||||
options = 0;
|
||||
const CCompressionMethodMode *additionalStreamsOptions = options;
|
||||
if (!headerOptions.UseAdditionalHeaderStreams)
|
||||
additionalStreamsOptions = 0;
|
||||
/*
|
||||
if (database.Files.Size() < 2)
|
||||
compressMainHeader = false;
|
||||
*/
|
||||
if (options != 0)
|
||||
if (options->PasswordIsDefined || headerOptions.CompressMainHeader)
|
||||
_dynamicMode = true;
|
||||
RINOK(WriteHeader(database, additionalStreamsOptions, headerOptions, headerOffset));
|
||||
RINOK(WriteHeader(database, headerOptions, headerOffset));
|
||||
|
||||
if (_dynamicMode)
|
||||
{
|
||||
@@ -1083,14 +971,16 @@ HRESULT COutArchive::WriteDatabase(const CArchiveDatabase &database,
|
||||
CEncoder encoder(headerOptions.CompressMainHeader ? *options : encryptOptions);
|
||||
CRecordVector<UInt64> packSizes;
|
||||
CObjectVector<CFolder> folders;
|
||||
RINOK(EncodeStream(encoder, _dynamicBuffer,
|
||||
RINOK(EncodeStream(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
encoder, _dynamicBuffer,
|
||||
_dynamicBuffer.GetSize(), packSizes, folders));
|
||||
_dynamicMode = false;
|
||||
_mainMode = true;
|
||||
|
||||
_outByte.SetStream(SeqStream);
|
||||
_outByte.Init();
|
||||
_crc.Init();
|
||||
_crc = CRC_INIT_VAL;
|
||||
|
||||
if (folders.Size() == 0)
|
||||
throw 1;
|
||||
@@ -1098,13 +988,13 @@ HRESULT COutArchive::WriteDatabase(const CArchiveDatabase &database,
|
||||
RINOK(WriteID(NID::kEncodedHeader));
|
||||
RINOK(WritePackInfo(headerOffset, packSizes,
|
||||
CRecordVector<bool>(), CRecordVector<UInt32>()));
|
||||
RINOK(WriteUnPackInfo(false, 0, folders));
|
||||
RINOK(WriteUnPackInfo(folders));
|
||||
RINOK(WriteByte(NID::kEnd));
|
||||
for (int i = 0; i < packSizes.Size(); i++)
|
||||
headerOffset += packSizes[i];
|
||||
RINOK(_outByte.Flush());
|
||||
}
|
||||
headerCRC = _crc.GetDigest();
|
||||
headerCRC = CRC_GET_DIGEST(_crc);
|
||||
headerSize = _outByte.GetProcessedSize();
|
||||
}
|
||||
#ifdef _7Z_VOL
|
||||
|
||||
+16
-15
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "../../Common/OutBuffer.h"
|
||||
#include "../../../Common/DynamicBuffer.h"
|
||||
#include "../../../Common/CRC.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
@@ -62,14 +61,14 @@ public:
|
||||
|
||||
struct CHeaderOptions
|
||||
{
|
||||
bool UseAdditionalHeaderStreams;
|
||||
// bool UseAdditionalHeaderStreams;
|
||||
bool CompressMainHeader;
|
||||
bool WriteModified;
|
||||
bool WriteCreated;
|
||||
bool WriteAccessed;
|
||||
|
||||
CHeaderOptions():
|
||||
UseAdditionalHeaderStreams(false),
|
||||
// UseAdditionalHeaderStreams(false),
|
||||
CompressMainHeader(true),
|
||||
WriteModified(true),
|
||||
WriteCreated(false),
|
||||
@@ -105,10 +104,7 @@ class COutArchive
|
||||
const CRecordVector<bool> &packCRCsDefined,
|
||||
const CRecordVector<UInt32> &packCRCs);
|
||||
|
||||
HRESULT WriteUnPackInfo(
|
||||
bool externalFolders,
|
||||
CNum externalFoldersStreamIndex,
|
||||
const CObjectVector<CFolder> &folders);
|
||||
HRESULT WriteUnPackInfo(const CObjectVector<CFolder> &folders);
|
||||
|
||||
HRESULT WriteSubStreamsInfo(
|
||||
const CObjectVector<CFolder> &folders,
|
||||
@@ -133,15 +129,18 @@ class COutArchive
|
||||
*/
|
||||
|
||||
|
||||
HRESULT WriteTime(const CObjectVector<CFileItem> &files, Byte type,
|
||||
bool isExternal, CNum externalDataIndex);
|
||||
HRESULT WriteTime(const CObjectVector<CFileItem> &files, Byte type);
|
||||
|
||||
HRESULT EncodeStream(CEncoder &encoder, const Byte *data, size_t dataSize,
|
||||
HRESULT EncodeStream(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CEncoder &encoder, const Byte *data, size_t dataSize,
|
||||
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders);
|
||||
HRESULT EncodeStream(CEncoder &encoder, const CByteBuffer &data,
|
||||
HRESULT EncodeStream(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
CEncoder &encoder, const CByteBuffer &data,
|
||||
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders);
|
||||
HRESULT WriteHeader(const CArchiveDatabase &database,
|
||||
const CCompressionMethodMode *options,
|
||||
HRESULT WriteHeader(
|
||||
const CArchiveDatabase &database,
|
||||
const CHeaderOptions &headerOptions,
|
||||
UInt64 &headerOffset);
|
||||
|
||||
@@ -154,7 +153,7 @@ class COutArchive
|
||||
COutBuffer _outByte;
|
||||
CWriteBufferLoc _outByte2;
|
||||
CWriteDynamicBuffer _dynamicBuffer;
|
||||
CCRC _crc;
|
||||
UInt32 _crc;
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
bool _endMarker;
|
||||
@@ -176,7 +175,9 @@ public:
|
||||
HRESULT Create(ISequentialOutStream *stream, bool endMarker);
|
||||
void Close();
|
||||
HRESULT SkeepPrefixArchiveHeader();
|
||||
HRESULT WriteDatabase(const CArchiveDatabase &database,
|
||||
HRESULT WriteDatabase(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const CArchiveDatabase &database,
|
||||
const CCompressionMethodMode *options,
|
||||
const CHeaderOptions &headerOptions);
|
||||
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
// 7zRegister.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/RegisterArc.h"
|
||||
|
||||
#include "7zHandler.h"
|
||||
static IInArchive *CreateArc() { return new NArchive::N7z::CHandler; }
|
||||
#ifndef EXTRACT_ONLY
|
||||
static IOutArchive *CreateArcOut() { return new NArchive::N7z::CHandler; }
|
||||
#else
|
||||
#define CreateArcOut 0
|
||||
#endif
|
||||
|
||||
static CArcInfo g_ArcInfo =
|
||||
{ L"7z", L"7z", 0, 7, {'7' + 1 , 'z', 0xBC, 0xAF, 0x27, 0x1C}, 6, false, CreateArc, CreateArcOut };
|
||||
|
||||
REGISTER_ARC_DEC_SIG(7z)
|
||||
@@ -8,10 +8,6 @@
|
||||
#include "7zHandler.h"
|
||||
#include "7zOut.h"
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
#include "7zMethods.h"
|
||||
#endif
|
||||
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
@@ -108,13 +104,6 @@ struct CFolderRef
|
||||
|
||||
#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
|
||||
|
||||
static int CompareMethodIDs(const CMethodID &a1, const CMethodID &a2)
|
||||
{
|
||||
for (int i = 0; i < a1.IDSize && i < a2.IDSize; i++)
|
||||
RINOZ(MyCompare(a1.ID[i], a2.ID[i]));
|
||||
return MyCompare(a1.IDSize, a2.IDSize);
|
||||
}
|
||||
|
||||
static int CompareBuffers(const CByteBuffer &a1, const CByteBuffer &a2)
|
||||
{
|
||||
size_t c1 = a1.GetCapacity();
|
||||
@@ -125,22 +114,12 @@ static int CompareBuffers(const CByteBuffer &a1, const CByteBuffer &a2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int CompareAltCoders(const CAltCoderInfo &a1, const CAltCoderInfo &a2)
|
||||
{
|
||||
RINOZ(CompareMethodIDs(a1.MethodID, a2.MethodID));
|
||||
return CompareBuffers(a1.Properties, a2.Properties);
|
||||
}
|
||||
|
||||
static int CompareCoders(const CCoderInfo &c1, const CCoderInfo &c2)
|
||||
{
|
||||
RINOZ(MyCompare(c1.NumInStreams, c2.NumInStreams));
|
||||
RINOZ(MyCompare(c1.NumOutStreams, c2.NumOutStreams));
|
||||
int s1 = c1.AltCoders.Size();
|
||||
int s2 = c2.AltCoders.Size();
|
||||
RINOZ(MyCompare(s1, s2));
|
||||
for (int i = 0; i < s1; i++)
|
||||
RINOZ(CompareAltCoders(c1.AltCoders[i], c2.AltCoders[i]));
|
||||
return 0;
|
||||
RINOZ(MyCompare(c1.MethodID, c2.MethodID));
|
||||
return CompareBuffers(c1.Properties, c2.Properties);
|
||||
}
|
||||
|
||||
static int CompareBindPairs(const CBindPair &b1, const CBindPair &b2)
|
||||
@@ -371,28 +350,17 @@ static bool IsExeFile(const UString &ext)
|
||||
return false;
|
||||
}
|
||||
|
||||
static CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
static CMethodID k_BCJ2 = { { 0x3, 0x3, 0x1, 0x1B }, 4 };
|
||||
static CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
static const UInt64 k_Copy = 0x0;
|
||||
static const UInt64 k_LZMA = 0x030101;
|
||||
static const UInt64 k_BCJ = 0x03030103;
|
||||
static const UInt64 k_BCJ2 = 0x0303011B;
|
||||
|
||||
static bool GetMethodFull(const CMethodID &methodID,
|
||||
static bool GetMethodFull(UInt64 methodID,
|
||||
UInt32 numInStreams, CMethodFull &methodResult)
|
||||
{
|
||||
methodResult.MethodID = methodID;
|
||||
methodResult.NumInStreams = numInStreams;
|
||||
methodResult.NumOutStreams = 1;
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
CMethodInfo methodInfo;
|
||||
if (!GetMethodInfo(methodID, methodInfo))
|
||||
return false;
|
||||
if (!methodInfo.EncoderIsAssigned)
|
||||
return false;
|
||||
methodResult.EncoderClassID = methodInfo.Encoder;
|
||||
methodResult.FilePath = methodInfo.FilePath;
|
||||
if (methodInfo.NumOutStreams != 1 || methodInfo.NumInStreams != numInStreams)
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -455,7 +423,7 @@ static bool MakeExeMethod(const CCompressionMethodMode &method,
|
||||
else
|
||||
{
|
||||
CMethodFull methodFull;
|
||||
if (!GetMethodFull(k_BCJ_X86, 1, methodFull))
|
||||
if (!GetMethodFull(k_BCJ, 1, methodFull))
|
||||
return false;
|
||||
exeMethod.Methods.Insert(0, methodFull);
|
||||
CBind bind;
|
||||
@@ -537,6 +505,7 @@ static void FromUpdateItemToFileItem(const CUpdateItem &updateItem,
|
||||
}
|
||||
|
||||
static HRESULT Update2(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
const CArchiveDatabaseEx *database,
|
||||
const CObjectVector<CUpdateItem> &updateItems,
|
||||
@@ -775,8 +744,11 @@ static HRESULT Update2(
|
||||
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
|
||||
localCompressProgressSpec->Init(localProgress, &complexity, NULL);
|
||||
|
||||
RINOK(encoder.Encode(solidInStream, NULL, &inSizeForReduce, folderItem,
|
||||
archive.SeqStream, newDatabase.PackSizes, compressProgress));
|
||||
RINOK(encoder.Encode(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
solidInStream, NULL, &inSizeForReduce, folderItem,
|
||||
archive.SeqStream, newDatabase.PackSizes, compressProgress));
|
||||
|
||||
// for()
|
||||
// newDatabase.PackCRCsDefined.Add(false);
|
||||
// newDatabase.PackCRCs.Add(0);
|
||||
@@ -865,19 +837,17 @@ static HRESULT Update2(
|
||||
return E_FAIL;
|
||||
*/
|
||||
|
||||
return archive.WriteDatabase(newDatabase, options.HeaderMethod, options.HeaderOptions);
|
||||
return archive.WriteDatabase(EXTERNAL_CODECS_LOC_VARS
|
||||
newDatabase, options.HeaderMethod, options.HeaderOptions);
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
|
||||
static HRESULT WriteVolumeHeader(COutArchive &archive, CFileItem &file, const CUpdateOptions &options)
|
||||
{
|
||||
CAltCoderInfo altCoder;
|
||||
altCoder.MethodID.IDSize = 1;
|
||||
altCoder.MethodID.ID[0] = 0;
|
||||
CCoderInfo coder;
|
||||
coder.NumInStreams = coder.NumOutStreams = 1;
|
||||
coder.AltCoders.Add(altCoder);
|
||||
coder.MethodID = k_Copy;
|
||||
|
||||
CFolder folder;
|
||||
folder.Coders.Add(coder);
|
||||
@@ -1066,6 +1036,7 @@ STDMETHODIMP COutVolumeStream::Write(const void *data, UInt32 size, UInt32 *proc
|
||||
#endif
|
||||
|
||||
HRESULT Update(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
const CArchiveDatabaseEx *database,
|
||||
const CObjectVector<CUpdateItem> &updateItems,
|
||||
@@ -1076,7 +1047,9 @@ HRESULT Update(
|
||||
#ifdef _7Z_VOL
|
||||
if (seqOutStream)
|
||||
#endif
|
||||
return Update2(inStream, database, updateItems,
|
||||
return Update2(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
inStream, database, updateItems,
|
||||
seqOutStream, updateCallback, options);
|
||||
#ifdef _7Z_VOL
|
||||
if (options.VolumeMode)
|
||||
|
||||
@@ -68,6 +68,7 @@ struct CUpdateOptions
|
||||
};
|
||||
|
||||
HRESULT Update(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IInStream *inStream,
|
||||
const CArchiveDatabaseEx *database,
|
||||
const CObjectVector<CUpdateItem> &updateItems,
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/MyInitGuid.h"
|
||||
#include "../../../Common/ComTry.h"
|
||||
#ifdef _WIN32
|
||||
#include "../../../Common/Alloc.h"
|
||||
#endif
|
||||
|
||||
#include "../../ICoder.h"
|
||||
|
||||
#include "7zHandler.h"
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
// {23170F69-40C1-278B-06F1-070100000100}
|
||||
DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x01, 0x00);
|
||||
#endif
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
if (!::GetVersionEx(&versionInfo))
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
SetLargePageSize();
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID != NArchive::N7z::CLSID_CFormat7z)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
if (*interfaceID == IID_IInArchive)
|
||||
{
|
||||
CMyComPtr<IInArchive> inArchive = new NArchive::N7z::CHandler;
|
||||
*outObject = inArchive.Detach();
|
||||
}
|
||||
#ifndef EXTRACT_ONLY
|
||||
else if (*interfaceID == IID_IOutArchive)
|
||||
{
|
||||
CMyComPtr<IOutArchive> outArchive = new NArchive::N7z::CHandler;
|
||||
*outObject = outArchive.Detach();
|
||||
}
|
||||
#endif
|
||||
else
|
||||
return E_NOINTERFACE;
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
switch(propID)
|
||||
{
|
||||
case NArchive::kName:
|
||||
propVariant = L"7z";
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&NArchive::N7z::CLSID_CFormat7z, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"7z";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = true;
|
||||
break;
|
||||
case NArchive::kKeepName:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen((const char *)NArchive::N7z::kSignature,
|
||||
NArchive::N7z::kSignatureSize)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
PROG = 7z.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT
|
||||
CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DCOMPRESS_MT \
|
||||
-DEXTERNAL_CODECS \
|
||||
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
AR_OBJS = \
|
||||
$O\ArchiveExports.obj \
|
||||
$O\DllExports.obj \
|
||||
|
||||
7Z_OBJS = \
|
||||
$O\7zCompressionMode.obj \
|
||||
$O\7zDecode.obj \
|
||||
@@ -14,16 +21,13 @@ LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
$O\7zHandlerOut.obj \
|
||||
$O\7zHeader.obj \
|
||||
$O\7zIn.obj \
|
||||
$O\7zMethodID.obj \
|
||||
$O\7zMethods.obj \
|
||||
$O\7zOut.obj \
|
||||
$O\7zProperties.obj \
|
||||
$O\7zSpecStream.obj \
|
||||
$O\7zUpdate.obj \
|
||||
$O\DllExports.obj \
|
||||
$O\7zRegister.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\CRC.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
@@ -41,9 +45,12 @@ WIN_OBJS = \
|
||||
$O\Synchronization.obj
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\CreateCoder.obj \
|
||||
$O\InOutTempBuffer.obj \
|
||||
$O\FilterCoder.obj \
|
||||
$O\LimitedStreams.obj \
|
||||
$O\LockedStream.obj \
|
||||
$O\MethodId.obj \
|
||||
$O\OutBuffer.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamBinder.obj \
|
||||
@@ -51,30 +58,37 @@ WIN_OBJS = \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CodecsPath.obj \
|
||||
$O\CoderLoader.obj \
|
||||
$O\CoderMixer2.obj \
|
||||
$O\CoderMixer2MT.obj \
|
||||
$O\CrossThreadProgress.obj \
|
||||
$O\FilterCoder.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\MultiStream.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
|
||||
!include "../../Crc2.mak"
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(AR_OBJS) \
|
||||
$(7Z_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(AR_COMMON_OBJS) \
|
||||
$O\CopyCoder.obj \
|
||||
$(C_OBJS) \
|
||||
$(CRC_OBJS) \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(AR_OBJS): ../$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7Z_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
@@ -87,3 +101,6 @@ $(AR_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(C_OBJS): ../../../../C/$(*B).c
|
||||
$(COMPL_O2)
|
||||
!include "../../Crc.mak"
|
||||
|
||||
Reference in New Issue
Block a user