mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-18 14:11:54 -06:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ec42ff829 | ||
|
|
631462beb2 | ||
|
|
bd9a40b0ed | ||
|
|
3415684502 | ||
|
|
83911c8529 | ||
|
|
cb9eea7264 | ||
|
|
8304895f29 | ||
|
|
191cf6781a | ||
|
|
0f60a4933b | ||
|
|
02516d3fce |
@@ -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 "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /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" /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 "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /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" /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"
|
||||
@@ -254,10 +254,6 @@ SOURCE=..\..\ICoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\ICoderProperties.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\IMyUnknown.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -436,6 +432,14 @@ SOURCE=..\Common\OutStreamWithCRC.cpp
|
||||
|
||||
SOURCE=..\Common\OutStreamWithCRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7-Zip Common"
|
||||
|
||||
|
||||
@@ -45,12 +45,18 @@ struct CCompressionMethodMode
|
||||
{
|
||||
CObjectVector<CMethodFull> Methods;
|
||||
CRecordVector<CBind> Binds;
|
||||
bool MultiThread;
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 NumThreads;
|
||||
#endif
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
bool IsEmpty() const { return (Methods.IsEmpty() && !PasswordIsDefined); }
|
||||
CCompressionMethodMode(): PasswordIsDefined(false), MultiThread(false) {}
|
||||
CCompressionMethodMode(): PasswordIsDefined(false)
|
||||
#ifdef COMPRESS_MT
|
||||
, NumThreads(1)
|
||||
#endif
|
||||
{}
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -155,6 +155,9 @@ HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getTextPassword
|
||||
#endif
|
||||
#ifdef COMPRESS_MT
|
||||
, bool mtMode, UInt32 numThreads
|
||||
#endif
|
||||
)
|
||||
{
|
||||
CObjectVector< CMyComPtr<ISequentialInStream> > inStreams;
|
||||
@@ -329,50 +332,60 @@ HRESULT CDecoder::Decode(IInStream *inStream,
|
||||
{
|
||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||
const CAltCoderInfo &altCoderInfo = coderInfo.AltCoders.Front();
|
||||
CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
|
||||
HRESULT result = _decoders[coderIndex].QueryInterface(
|
||||
IID_ICompressSetDecoderProperties2, &compressSetDecoderProperties);
|
||||
CMyComPtr<IUnknown> &decoder = _decoders[coderIndex];
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
const CByteBuffer &properties = altCoderInfo.Properties;
|
||||
size_t size = properties.GetCapacity();
|
||||
if (size > 0xFFFFFFFF)
|
||||
return E_NOTIMPL;
|
||||
if (size > 0)
|
||||
CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
|
||||
HRESULT result = decoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
|
||||
if (setDecoderProperties)
|
||||
{
|
||||
RINOK(compressSetDecoderProperties->SetDecoderProperties2((const Byte *)properties, (UInt32)size));
|
||||
const CByteBuffer &properties = altCoderInfo.Properties;
|
||||
size_t size = properties.GetCapacity();
|
||||
if (size > 0xFFFFFFFF)
|
||||
return E_NOTIMPL;
|
||||
if (size > 0)
|
||||
{
|
||||
RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)properties, (UInt32)size));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (result != E_NOINTERFACE)
|
||||
return result;
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
if (mtMode)
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
||||
decoder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
|
||||
if (setCoderMt)
|
||||
{
|
||||
RINOK(setCoderMt->SetNumberOfThreads(numThreads));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
|
||||
result = _decoders[coderIndex].QueryInterface(
|
||||
IID_ICryptoSetPassword, &cryptoSetPassword);
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
if (getTextPassword == 0)
|
||||
return E_FAIL;
|
||||
CMyComBSTR password;
|
||||
RINOK(getTextPassword->CryptoGetTextPassword(&password));
|
||||
CByteBuffer buffer;
|
||||
UString unicodePassword(password);
|
||||
const UInt32 sizeInBytes = unicodePassword.Length() * 2;
|
||||
buffer.SetCapacity(sizeInBytes);
|
||||
for (int i = 0; i < unicodePassword.Length(); i++)
|
||||
CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
|
||||
HRESULT result = decoder.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword);
|
||||
if (cryptoSetPassword)
|
||||
{
|
||||
wchar_t c = unicodePassword[i];
|
||||
((Byte *)buffer)[i * 2] = (Byte)c;
|
||||
((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
|
||||
if (getTextPassword == 0)
|
||||
return E_FAIL;
|
||||
CMyComBSTR password;
|
||||
RINOK(getTextPassword->CryptoGetTextPassword(&password));
|
||||
CByteBuffer buffer;
|
||||
UString unicodePassword(password);
|
||||
const UInt32 sizeInBytes = unicodePassword.Length() * 2;
|
||||
buffer.SetCapacity(sizeInBytes);
|
||||
for (int i = 0; i < unicodePassword.Length(); i++)
|
||||
{
|
||||
wchar_t c = unicodePassword[i];
|
||||
((Byte *)buffer)[i * 2] = (Byte)c;
|
||||
((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
|
||||
}
|
||||
RINOK(cryptoSetPassword->CryptoSetPassword(
|
||||
(const Byte *)buffer, sizeInBytes));
|
||||
}
|
||||
RINOK(cryptoSetPassword->CryptoSetPassword(
|
||||
(const Byte *)buffer, sizeInBytes));
|
||||
}
|
||||
else if (result != E_NOINTERFACE)
|
||||
return result;
|
||||
#endif
|
||||
|
||||
coderIndex++;
|
||||
|
||||
@@ -60,6 +60,9 @@ public:
|
||||
#ifndef _NO_CRYPTO
|
||||
, ICryptoGetTextPassword *getTextPasswordSpec
|
||||
#endif
|
||||
#ifdef COMPRESS_MT
|
||||
, bool mtMode, UInt32 numThreads
|
||||
#endif
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -228,7 +228,20 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
reducedDictionarySize += step;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CMyComPtr<IUnknown> encoderCommon = methodFull.IsSimpleCoder() ? (IUnknown *)encoder : (IUnknown *)encoder2;
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
||||
encoderCommon.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
|
||||
if (setCoderMt)
|
||||
{
|
||||
RINOK(setCoderMt->SetNumberOfThreads(_options.NumThreads));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (methodFull.CoderProperties.Size() > 0)
|
||||
{
|
||||
CRecordVector<PROPID> propIDs;
|
||||
@@ -246,16 +259,7 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
values[i] = value;
|
||||
}
|
||||
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
|
||||
if (methodFull.IsSimpleCoder())
|
||||
{
|
||||
RINOK(encoder.QueryInterface(IID_ICompressSetCoderProperties,
|
||||
&setCoderProperties));
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(encoder2.QueryInterface(IID_ICompressSetCoderProperties,
|
||||
&setCoderProperties));
|
||||
}
|
||||
RINOK(encoderCommon.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties));
|
||||
RINOK(setCoderProperties->SetCoderProperties(&propIDs.Front(), values, numProperties));
|
||||
}
|
||||
catch(...)
|
||||
@@ -268,16 +272,7 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
|
||||
CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
|
||||
|
||||
if (methodFull.IsSimpleCoder())
|
||||
{
|
||||
encoder.QueryInterface(IID_ICompressWriteCoderProperties,
|
||||
&writeCoderProperties);
|
||||
}
|
||||
else
|
||||
{
|
||||
encoder2.QueryInterface(IID_ICompressWriteCoderProperties,
|
||||
&writeCoderProperties);
|
||||
}
|
||||
encoderCommon.QueryInterface(IID_ICompressWriteCoderProperties, &writeCoderProperties);
|
||||
|
||||
if (writeCoderProperties != NULL)
|
||||
{
|
||||
@@ -298,14 +293,7 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
}
|
||||
|
||||
CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
|
||||
if (methodFull.IsSimpleCoder())
|
||||
{
|
||||
encoder.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
encoder2.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword);
|
||||
}
|
||||
encoderCommon.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword);
|
||||
|
||||
if (cryptoSetPassword)
|
||||
{
|
||||
@@ -318,19 +306,13 @@ HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
|
||||
((Byte *)buffer)[i * 2] = (Byte)c;
|
||||
((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
|
||||
}
|
||||
RINOK(cryptoSetPassword->CryptoSetPassword(
|
||||
(const Byte *)buffer, sizeInBytes));
|
||||
RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, sizeInBytes));
|
||||
}
|
||||
|
||||
// public ICompressWriteCoderProperties,
|
||||
if (methodFull.IsSimpleCoder())
|
||||
{
|
||||
_mixerCoderSpec->AddCoder(encoder);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mixerCoderSpec->AddCoder2(encoder2);
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
bool testMode = (testModeSpec != 0);
|
||||
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
|
||||
UInt64 importantTotalUnPacked = 0;
|
||||
UInt64 censoredTotalUnPacked = 0, censoredTotalPacked = 0;
|
||||
|
||||
bool allFilesMode = (numItems == UInt32(-1));
|
||||
if (allFilesMode)
|
||||
@@ -230,6 +229,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
#ifndef _NO_CRYPTO
|
||||
, getTextPassword
|
||||
#endif
|
||||
#ifdef COMPRESS_MT
|
||||
, true, _numThreads
|
||||
#endif
|
||||
);
|
||||
|
||||
if (result == S_FALSE)
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
#include "../Common/MultiStream.h"
|
||||
#endif
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
#ifdef EXTRACT_ONLY
|
||||
#include "../Common/ParseProperties.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
@@ -21,6 +27,9 @@ namespace N7z {
|
||||
|
||||
CHandler::CHandler()
|
||||
{
|
||||
#ifdef COMPRESS_MT
|
||||
_numThreads = NWindows::NSystem::GetNumberOfProcessors();
|
||||
#endif
|
||||
#ifndef EXTRACT_ONLY
|
||||
Init();
|
||||
#endif
|
||||
@@ -708,4 +717,41 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
#ifdef EXTRACT_ONLY
|
||||
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
|
||||
_numThreads = numProcessors;
|
||||
|
||||
for (int i = 0; i < numProperties; i++)
|
||||
{
|
||||
UString name = names[i];
|
||||
name.MakeUpper();
|
||||
if (name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
const PROPVARIANT &value = values[i];
|
||||
UInt32 number;
|
||||
int index = ParseStringToUInt32(name, number);
|
||||
if (index == 0)
|
||||
{
|
||||
if(name.Left(2).CompareNoCase(L"MT") == 0)
|
||||
{
|
||||
RINOK(ParseMtProp(name.Mid(2), value, numProcessors, _numThreads));
|
||||
continue;
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
#include "7zMethods.h"
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
@@ -54,14 +58,29 @@ struct COneMethodInfo
|
||||
DEFINE_GUID(CLSID_CFormat7z,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
|
||||
|
||||
#ifndef __7Z_SET_PROPERTIES
|
||||
|
||||
#ifdef EXTRACT_ONLY
|
||||
#ifdef COMPRESS_MT
|
||||
#define __7Z_SET_PROPERTIES
|
||||
#endif
|
||||
#else
|
||||
#define __7Z_SET_PROPERTIES
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
class CHandler:
|
||||
public IInArchive,
|
||||
#ifdef _7Z_VOL
|
||||
public IInArchiveGetStream,
|
||||
#endif
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
public ISetProperties,
|
||||
#endif
|
||||
#ifndef EXTRACT_ONLY
|
||||
public IOutArchive,
|
||||
public ISetProperties,
|
||||
#endif
|
||||
public CMyUnknownImp
|
||||
{
|
||||
@@ -70,9 +89,11 @@ public:
|
||||
#ifdef _7Z_VOL
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
|
||||
#endif
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
#endif
|
||||
#ifndef EXTRACT_ONLY
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
#endif
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
@@ -101,6 +122,10 @@ public:
|
||||
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
|
||||
#endif
|
||||
|
||||
#ifdef __7Z_SET_PROPERTIES
|
||||
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
|
||||
#endif
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
// IOutArchiveHandler
|
||||
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
|
||||
@@ -109,7 +134,6 @@ public:
|
||||
STDMETHOD(GetFileTimeType)(UInt32 *type);
|
||||
|
||||
// ISetProperties
|
||||
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
|
||||
|
||||
HRESULT SetSolidSettings(const UString &s);
|
||||
HRESULT SetSolidSettings(const PROPVARIANT &value);
|
||||
@@ -126,6 +150,10 @@ private:
|
||||
NArchive::N7z::CArchiveDatabaseEx _database;
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 _numThreads;
|
||||
#endif
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
CObjectVector<COneMethodInfo> _methods;
|
||||
CRecordVector<CBind> _binds;
|
||||
@@ -139,23 +167,7 @@ private:
|
||||
bool _compressHeadersFull;
|
||||
bool _encryptHeaders;
|
||||
|
||||
bool _copyMode;
|
||||
|
||||
UInt32 _defaultDicSize;
|
||||
UInt32 _defaultAlgorithm;
|
||||
UInt32 _defaultFastBytes;
|
||||
UString _defaultMatchFinder;
|
||||
|
||||
UInt32 _defaultBZip2Passes;
|
||||
|
||||
UInt32 _defaultPpmdMemSize;
|
||||
UInt32 _defaultPpmdOrder;
|
||||
|
||||
UInt32 _defaultDeflateFastBytes;
|
||||
UInt32 _defaultDeflatePasses;
|
||||
|
||||
bool _autoFilter;
|
||||
bool _multiThread;
|
||||
UInt32 _level;
|
||||
|
||||
bool _volumeMode;
|
||||
@@ -168,8 +180,11 @@ private:
|
||||
IArchiveUpdateCallback *updateCallback);
|
||||
|
||||
HRESULT SetCompressionMethod(CCompressionMethodMode &method,
|
||||
CObjectVector<COneMethodInfo> &methodsInfo,
|
||||
bool multiThread);
|
||||
CObjectVector<COneMethodInfo> &methodsInfo
|
||||
#ifdef COMPRESS_MT
|
||||
, UInt32 numThreads
|
||||
#endif
|
||||
);
|
||||
|
||||
HRESULT SetCompressionMethod(
|
||||
CCompressionMethodMode &method,
|
||||
@@ -195,30 +210,6 @@ private:
|
||||
_solidExtension = false;
|
||||
_numSolidBytesDefined = false;
|
||||
}
|
||||
/*
|
||||
void InitSolidPart()
|
||||
{
|
||||
if (_numSolidFiles <= 1)
|
||||
InitSolidFiles();
|
||||
}
|
||||
*/
|
||||
void SetSolidBytesLimit()
|
||||
{
|
||||
_numSolidBytes = ((UInt64)_defaultDicSize) << 7;
|
||||
const UInt64 kMinSize = (1<<24);
|
||||
if (_numSolidBytes < kMinSize)
|
||||
_numSolidBytes = kMinSize;
|
||||
}
|
||||
void CheckAndSetSolidBytesLimit()
|
||||
{
|
||||
if (!_numSolidBytesDefined)
|
||||
{
|
||||
if (_copyMode)
|
||||
_numSolidBytes = 0;
|
||||
else
|
||||
SetSolidBytesLimit();
|
||||
}
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
@@ -226,27 +217,14 @@ private:
|
||||
_compressHeaders = true;
|
||||
_compressHeadersFull = true;
|
||||
_encryptHeaders = false;
|
||||
_multiThread = false;
|
||||
_copyMode = false;
|
||||
|
||||
_defaultDicSize = (1 << 21);
|
||||
_defaultAlgorithm = 1;
|
||||
_defaultFastBytes = 32;
|
||||
_defaultMatchFinder = L"BT4";
|
||||
|
||||
_defaultBZip2Passes = 1;
|
||||
|
||||
_defaultPpmdMemSize = (1 << 24);
|
||||
_defaultPpmdOrder = 6;
|
||||
|
||||
_defaultDeflateFastBytes = 32;
|
||||
_defaultDeflatePasses = 1;
|
||||
#ifdef COMPRESS_MT
|
||||
_numThreads = NWindows::NSystem::GetNumberOfProcessors();
|
||||
#endif
|
||||
|
||||
_level = 5;
|
||||
_autoFilter = true;
|
||||
_volumeMode = false;
|
||||
InitSolid();
|
||||
SetSolidBytesLimit();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
#include "7zMethods.h"
|
||||
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
|
||||
#include "../../../Common/ComTry.h"
|
||||
#include "../../../Common/StringToInt.h"
|
||||
#include "../../IPassword.h"
|
||||
#include "../../ICoder.h"
|
||||
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
#include "../Common/ParseProperties.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
@@ -67,36 +69,56 @@ const wchar_t *kPpmdMethodName = L"PPMd";
|
||||
const wchar_t *kDeflateMethodName = L"Deflate";
|
||||
const wchar_t *kDeflate64MethodName = L"Deflate64";
|
||||
|
||||
const UInt32 kAlgorithmForX7 = 2;
|
||||
const UInt32 kDicSizeForX7 = 1 << 23;
|
||||
const UInt32 kFastBytesForX7 = 64;
|
||||
static const wchar_t *kLzmaMatchFinderX1 = L"HC4";
|
||||
static const wchar_t *kLzmaMatchFinderX5 = L"BT4";
|
||||
|
||||
const UInt32 kAlgorithmForX9 = 2;
|
||||
const UInt32 kDicSizeForX9 = 1 << 25;
|
||||
const UInt32 kFastBytesForX9 = 64;
|
||||
static const wchar_t *kMatchFinderForX9 = L"BT4b";
|
||||
static const UInt32 kLzmaAlgorithmX1 = 0;
|
||||
static const UInt32 kLzmaAlgorithmX5 = 1;
|
||||
|
||||
const UInt32 kAlgorithmForFast = 0;
|
||||
const UInt32 kDicSizeForFast = 1 << 15;
|
||||
static const wchar_t *kMatchFinderForFast = L"HC3";
|
||||
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 kLzmaDicSizeX9 = 1 << 26;
|
||||
|
||||
const UInt32 kPpmdMemSizeX1 = (1 << 22);
|
||||
const UInt32 kPpmdOrderX1 = 4;
|
||||
static const UInt32 kLzmaFastBytesX1 = 32;
|
||||
static const UInt32 kLzmaFastBytesX7 = 64;
|
||||
|
||||
const UInt32 kPpmdMemSizeX7 = (1 << 26);
|
||||
const UInt32 kPpmdOrderX7 = 16;
|
||||
static const UInt32 kPpmdMemSizeX1 = (1 << 22);
|
||||
static const UInt32 kPpmdMemSizeX5 = (1 << 24);
|
||||
static const UInt32 kPpmdMemSizeX7 = (1 << 26);
|
||||
static const UInt32 kPpmdMemSizeX9 = (192 << 20);
|
||||
|
||||
const UInt32 kPpmdMemSizeX9 = (192 << 20);
|
||||
const UInt32 kPpmdOrderX9 = 32;
|
||||
static const UInt32 kPpmdOrderX1 = 4;
|
||||
static const UInt32 kPpmdOrderX5 = 6;
|
||||
static const UInt32 kPpmdOrderX7 = 16;
|
||||
static const UInt32 kPpmdOrderX9 = 32;
|
||||
|
||||
const UInt32 kDeflateFastBytesForX7 = 64;
|
||||
const UInt32 kDeflatePassesForX7 = 3;
|
||||
static const UInt32 kDeflateFastBytesX1 = 32;
|
||||
static const UInt32 kDeflateFastBytesX7 = 64;
|
||||
static const UInt32 kDeflateFastBytesX9 = 128;
|
||||
|
||||
static const UInt32 kDeflatePassesX1 = 1;
|
||||
static const UInt32 kDeflatePassesX7 = 3;
|
||||
static const UInt32 kDeflatePassesX9 = 10;
|
||||
|
||||
static const UInt32 kBZip2NumPassesX1 = 1;
|
||||
static const UInt32 kBZip2NumPassesX7 = 2;
|
||||
static const UInt32 kBZip2NumPassesX9 = 7;
|
||||
|
||||
static const UInt32 kBZip2DicSizeX1 = 100000;
|
||||
static const UInt32 kBZip2DicSizeX3 = 500000;
|
||||
static const UInt32 kBZip2DicSizeX5 = 900000;
|
||||
|
||||
const wchar_t *kDefaultMethodName = kLZMAMethodName;
|
||||
|
||||
static const wchar_t *kMatchFinderForHeaders = L"BT2";
|
||||
static const wchar_t *kLzmaMatchFinderForHeaders = L"BT2";
|
||||
static const UInt32 kDictionaryForHeaders = 1 << 20;
|
||||
static const UInt32 kNumFastBytesForHeaders = 273;
|
||||
static const UInt32 kAlgorithmForHeaders = kLzmaAlgorithmX5;
|
||||
|
||||
static bool IsCopyMethod(const UString &methodName)
|
||||
{ return (methodName.CompareNoCase(kCopyMethod) == 0); }
|
||||
|
||||
static bool IsLZMAMethod(const UString &methodName)
|
||||
{ return (methodName.CompareNoCase(kLZMAMethodName) == 0); }
|
||||
@@ -159,9 +181,10 @@ CNameToPropID g_NameToPropID[] =
|
||||
|
||||
{ NCoderPropID::kNumPasses, VT_UI4, L"Pass" },
|
||||
{ NCoderPropID::kNumFastBytes, VT_UI4, L"fb" },
|
||||
{ NCoderPropID::kMatchFinderCycles, VT_UI4, L"mc" },
|
||||
{ NCoderPropID::kAlgorithm, VT_UI4, L"a" },
|
||||
{ NCoderPropID::kMatchFinder, VT_BSTR, L"mf" },
|
||||
{ NCoderPropID::kMultiThread, VT_BOOL, L"mt" }
|
||||
{ NCoderPropID::kNumThreads, VT_UI4, L"mt" }
|
||||
};
|
||||
|
||||
bool ConvertProperty(PROPVARIANT srcProp, VARTYPE varType,
|
||||
@@ -200,7 +223,12 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
CCompressionMethodMode &methodMode,
|
||||
CCompressionMethodMode &headerMethod)
|
||||
{
|
||||
RINOK(SetCompressionMethod(methodMode, _methods, _multiThread));
|
||||
HRESULT res = SetCompressionMethod(methodMode, _methods
|
||||
#ifdef COMPRESS_MT
|
||||
, _numThreads
|
||||
#endif
|
||||
);
|
||||
RINOK(res);
|
||||
methodMode.Binds = _binds;
|
||||
if (_compressHeadersFull)
|
||||
_compressHeaders = true;
|
||||
@@ -215,13 +243,13 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
{
|
||||
CProperty property;
|
||||
property.PropID = NCoderPropID::kMatchFinder;
|
||||
property.Value = kMatchFinderForHeaders;
|
||||
property.Value = kLzmaMatchFinderForHeaders;
|
||||
oneMethodInfo.CoderProperties.Add(property);
|
||||
}
|
||||
{
|
||||
CProperty property;
|
||||
property.PropID = NCoderPropID::kAlgorithm;
|
||||
property.Value = kAlgorithmForX9;
|
||||
property.Value = kAlgorithmForHeaders;
|
||||
oneMethodInfo.CoderProperties.Add(property);
|
||||
}
|
||||
{
|
||||
@@ -237,7 +265,12 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
oneMethodInfo.CoderProperties.Add(property);
|
||||
}
|
||||
headerMethodInfoVector.Add(oneMethodInfo);
|
||||
RINOK(SetCompressionMethod(headerMethod, headerMethodInfoVector, false));
|
||||
HRESULT res = SetCompressionMethod(headerMethod, headerMethodInfoVector
|
||||
#ifdef COMPRESS_MT
|
||||
,1
|
||||
#endif
|
||||
);
|
||||
RINOK(res);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -259,8 +292,11 @@ static void SetOneMethodProp(COneMethodInfo &oneMethodInfo, PROPID propID,
|
||||
|
||||
HRESULT CHandler::SetCompressionMethod(
|
||||
CCompressionMethodMode &methodMode,
|
||||
CObjectVector<COneMethodInfo> &methodsInfo,
|
||||
bool multiThread)
|
||||
CObjectVector<COneMethodInfo> &methodsInfo
|
||||
#ifdef COMPRESS_MT
|
||||
, UInt32 numThreads
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifndef EXCLUDE_COM
|
||||
/*
|
||||
@@ -271,41 +307,103 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
#endif
|
||||
|
||||
|
||||
UInt32 level = _level;
|
||||
|
||||
if (methodsInfo.IsEmpty())
|
||||
{
|
||||
COneMethodInfo oneMethodInfo;
|
||||
oneMethodInfo.MethodName = _copyMode ? kCopyMethod : kDefaultMethodName;
|
||||
oneMethodInfo.MethodName = ((level == 0) ? kCopyMethod : kDefaultMethodName);
|
||||
methodsInfo.Add(oneMethodInfo);
|
||||
}
|
||||
|
||||
bool needSolid = false;
|
||||
for(int i = 0; i < methodsInfo.Size(); i++)
|
||||
{
|
||||
COneMethodInfo &oneMethodInfo = methodsInfo[i];
|
||||
if (oneMethodInfo.MethodName.IsEmpty())
|
||||
oneMethodInfo.MethodName = kDefaultMethodName;
|
||||
|
||||
if (!IsCopyMethod(oneMethodInfo.MethodName))
|
||||
needSolid = true;
|
||||
|
||||
if (IsLZMAMethod(oneMethodInfo.MethodName))
|
||||
{
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, _defaultDicSize);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, _defaultAlgorithm);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, _defaultFastBytes);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kMatchFinder, (const wchar_t *)_defaultMatchFinder);
|
||||
if (multiThread)
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kMultiThread, true);
|
||||
UInt32 dicSize =
|
||||
(level >= 9 ? kLzmaDicSizeX9 :
|
||||
(level >= 7 ? kLzmaDicSizeX7 :
|
||||
(level >= 5 ? kLzmaDicSizeX5 :
|
||||
(level >= 3 ? kLzmaDicSizeX3 :
|
||||
kLzmaDicSizeX1))));
|
||||
|
||||
UInt32 algorithm =
|
||||
(level >= 5 ? kLzmaAlgorithmX5 :
|
||||
kLzmaAlgorithmX1);
|
||||
|
||||
UInt32 fastBytes =
|
||||
(level >= 7 ? kLzmaFastBytesX7 :
|
||||
kLzmaFastBytesX1);
|
||||
|
||||
const wchar_t *matchFinder =
|
||||
(level >= 5 ? kLzmaMatchFinderX5 :
|
||||
kLzmaMatchFinderX1);
|
||||
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algorithm);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kMatchFinder, matchFinder);
|
||||
#ifdef COMPRESS_MT
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
|
||||
#endif
|
||||
}
|
||||
else if (IsDeflateMethod(oneMethodInfo.MethodName))
|
||||
{
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, _defaultDeflateFastBytes);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, _defaultDeflatePasses);
|
||||
UInt32 fastBytes =
|
||||
(level >= 9 ? kDeflateFastBytesX9 :
|
||||
(level >= 7 ? kDeflateFastBytesX7 :
|
||||
kDeflateFastBytesX1));
|
||||
|
||||
UInt32 numPasses =
|
||||
(level >= 9 ? kDeflatePassesX9 :
|
||||
(level >= 7 ? kDeflatePassesX7 :
|
||||
kDeflatePassesX1));
|
||||
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
|
||||
}
|
||||
else if (IsBZip2Method(oneMethodInfo.MethodName))
|
||||
{
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, _defaultBZip2Passes);
|
||||
UInt32 numPasses =
|
||||
(level >= 9 ? kBZip2NumPassesX9 :
|
||||
(level >= 7 ? kBZip2NumPassesX7 :
|
||||
kBZip2NumPassesX1));
|
||||
|
||||
UInt32 dicSize =
|
||||
(level >= 5 ? kBZip2DicSizeX5 :
|
||||
(level >= 3 ? kBZip2DicSizeX3 :
|
||||
kBZip2DicSizeX1));
|
||||
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
|
||||
#ifdef COMPRESS_MT
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
|
||||
#endif
|
||||
}
|
||||
else if (IsPpmdMethod(oneMethodInfo.MethodName))
|
||||
{
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kUsedMemorySize, _defaultPpmdMemSize);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kOrder, _defaultPpmdOrder);
|
||||
UInt32 useMemSize =
|
||||
(level >= 9 ? kPpmdMemSizeX9 :
|
||||
(level >= 7 ? kPpmdMemSizeX7 :
|
||||
(level >= 5 ? kPpmdMemSizeX5 :
|
||||
kPpmdMemSizeX1)));
|
||||
|
||||
UInt32 order =
|
||||
(level >= 9 ? kPpmdOrderX9 :
|
||||
(level >= 7 ? kPpmdOrderX7 :
|
||||
(level >= 5 ? kPpmdOrderX5 :
|
||||
kPpmdOrderX1)));
|
||||
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kUsedMemorySize, useMemSize);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kOrder, order);
|
||||
}
|
||||
|
||||
|
||||
@@ -406,6 +504,30 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
return E_FAIL;
|
||||
|
||||
methodMode.Methods.Add(methodFull);
|
||||
|
||||
if (!_numSolidBytesDefined)
|
||||
{
|
||||
for (int j = 0; j < methodFull.CoderProperties.Size(); j++)
|
||||
{
|
||||
const CProperty &prop = methodFull.CoderProperties[j];
|
||||
if ((prop.PropID == NCoderPropID::kDictionarySize ||
|
||||
prop.PropID == NCoderPropID::kUsedMemorySize) && prop.Value.vt == VT_UI4)
|
||||
{
|
||||
_numSolidBytes = ((UInt64)prop.Value.ulVal) << 7;
|
||||
const UInt64 kMinSize = (1 << 24);
|
||||
if (_numSolidBytes < kMinSize)
|
||||
_numSolidBytes = kMinSize;
|
||||
_numSolidBytesDefined = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!needSolid && !_numSolidBytesDefined)
|
||||
{
|
||||
_numSolidBytesDefined = true;
|
||||
_numSolidBytes = 0;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -437,7 +559,6 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
// CMyComPtr<IUpdateCallback2> updateCallback2;
|
||||
// updateCallback->QueryInterface(&updateCallback2);
|
||||
|
||||
int index = 0;
|
||||
for(UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
Int32 newData;
|
||||
@@ -569,35 +690,15 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
if (updateItem.Size != 0 && updateItem.IsAnti)
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
/*
|
||||
else
|
||||
thereIsCopyData = true;
|
||||
*/
|
||||
|
||||
updateItems.Add(updateItem);
|
||||
}
|
||||
|
||||
/*
|
||||
if (thereIsCopyData)
|
||||
{
|
||||
for(int i = 0; i < _database.NumUnPackStreamsVector.Size(); i++)
|
||||
if (_database.NumUnPackStreamsVector[i] != 1)
|
||||
return E_NOTIMPL;
|
||||
if (!_solidIsSpecified)
|
||||
_solid = false;
|
||||
if (_solid)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
CCompressionMethodMode methodMode, headerMethod;
|
||||
RINOK(SetCompressionMethod(methodMode, headerMethod));
|
||||
methodMode.MultiThread = _multiThread;
|
||||
// methodMode.MultiThreadMult = _multiThreadMult;
|
||||
|
||||
headerMethod.MultiThread = false;
|
||||
// headerMethod.MultiThreadMult = _multiThreadMult;
|
||||
#ifdef COMPRESS_MT
|
||||
methodMode.NumThreads = _numThreads;
|
||||
headerMethod.NumThreads = 1;
|
||||
#endif
|
||||
|
||||
RINOK(SetPassword(methodMode, updateCallback));
|
||||
|
||||
@@ -646,124 +747,6 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
static int ParseStringToUInt32(const UString &srcString, UInt32 &number)
|
||||
{
|
||||
const wchar_t *start = srcString;
|
||||
const wchar_t *end;
|
||||
UInt64 number64 = ConvertStringToUInt64(start, &end);
|
||||
if (number64 > 0xFFFFFFFF)
|
||||
{
|
||||
number = 0;
|
||||
return 0;
|
||||
}
|
||||
number = (UInt32)number64;
|
||||
return (int)(end - start);
|
||||
}
|
||||
|
||||
static const int kLogarithmicSizeLimit = 32;
|
||||
static const char kByteSymbol = 'B';
|
||||
static const char kKiloByteSymbol = 'K';
|
||||
static const char kMegaByteSymbol = 'M';
|
||||
|
||||
HRESULT ParseDictionaryValues(const UString &srcStringSpec, UInt32 &dicSize)
|
||||
{
|
||||
UString srcString = srcStringSpec;
|
||||
srcString.MakeUpper();
|
||||
|
||||
const wchar_t *start = srcString;
|
||||
const wchar_t *end;
|
||||
UInt64 number = ConvertStringToUInt64(start, &end);
|
||||
int numDigits = (int)(end - start);
|
||||
if (numDigits == 0 || srcString.Length() > numDigits + 1)
|
||||
return E_INVALIDARG;
|
||||
if (srcString.Length() == numDigits)
|
||||
{
|
||||
if (number >= kLogarithmicSizeLimit)
|
||||
return E_INVALIDARG;
|
||||
dicSize = (UInt32)1 << (int)number;
|
||||
return S_OK;
|
||||
}
|
||||
switch (srcString[numDigits])
|
||||
{
|
||||
case kByteSymbol:
|
||||
if (number >= ((UInt64)1 << kLogarithmicSizeLimit))
|
||||
return E_INVALIDARG;
|
||||
dicSize = (UInt32)number;
|
||||
break;
|
||||
case kKiloByteSymbol:
|
||||
if (number >= ((UInt64)1 << (kLogarithmicSizeLimit - 10)))
|
||||
return E_INVALIDARG;
|
||||
dicSize = UInt32(number << 10);
|
||||
break;
|
||||
case kMegaByteSymbol:
|
||||
if (number >= ((UInt64)1 << (kLogarithmicSizeLimit - 20)))
|
||||
return E_INVALIDARG;
|
||||
dicSize = UInt32(number << 20);
|
||||
break;
|
||||
default:
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static inline UINT GetCurrentFileCodePage()
|
||||
{
|
||||
return AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
}
|
||||
|
||||
static HRESULT SetBoolProperty(bool &dest, const PROPVARIANT &value)
|
||||
{
|
||||
switch(value.vt)
|
||||
{
|
||||
case VT_EMPTY:
|
||||
dest = true;
|
||||
break;
|
||||
/*
|
||||
case VT_UI4:
|
||||
dest = (value.ulVal != 0);
|
||||
break;
|
||||
*/
|
||||
case VT_BSTR:
|
||||
{
|
||||
UString valueString = value.bstrVal;
|
||||
valueString.MakeUpper();
|
||||
if (valueString.Compare(L"ON") == 0)
|
||||
dest = true;
|
||||
else if (valueString.Compare(L"OFF") == 0)
|
||||
dest = false;
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
static HRESULT SetComplexProperty(bool &boolStatus, UInt32 &number,
|
||||
const PROPVARIANT &value)
|
||||
{
|
||||
switch(value.vt)
|
||||
{
|
||||
case VT_EMPTY:
|
||||
case VT_BSTR:
|
||||
{
|
||||
RINOK(SetBoolProperty(boolStatus, value));
|
||||
return S_OK;
|
||||
}
|
||||
case VT_UI4:
|
||||
boolStatus = true;
|
||||
number = (value.ulVal);
|
||||
break;
|
||||
default:
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
static HRESULT GetBindInfoPart(UString &srcString, UInt32 &coder, UInt32 &stream)
|
||||
{
|
||||
stream = 0;
|
||||
@@ -843,7 +826,7 @@ HRESULT CHandler::SetParam(COneMethodInfo &oneMethodInfo, const UString &name, c
|
||||
if (name.CompareNoCase(L"D") == 0 || name.CompareNoCase(L"MEM") == 0)
|
||||
{
|
||||
UInt32 dicSize;
|
||||
RINOK(ParseDictionaryValues(value, dicSize));
|
||||
RINOK(ParsePropDictionaryValue(value, dicSize));
|
||||
if (name.CompareNoCase(L"D") == 0)
|
||||
property.PropID = NCoderPropID::kDictionarySize;
|
||||
else
|
||||
@@ -974,11 +957,17 @@ HRESULT CHandler::SetSolidSettings(const PROPVARIANT &value)
|
||||
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
|
||||
{
|
||||
UINT codePage = GetCurrentFileCodePage();
|
||||
COM_TRY_BEGIN
|
||||
_methods.Clear();
|
||||
_binds.Clear();
|
||||
Init();
|
||||
#ifdef COMPRESS_MT
|
||||
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
|
||||
#endif
|
||||
|
||||
UInt32 mainDicSize = 0xFFFFFFFF;
|
||||
UInt32 mainDicMethodIndex = 0xFFFFFFFF;
|
||||
|
||||
UInt32 minNumber = 0;
|
||||
|
||||
for (int i = 0; i < numProperties; i++)
|
||||
@@ -994,70 +983,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
{
|
||||
name.Delete(0);
|
||||
_level = 9;
|
||||
if (value.vt == VT_UI4)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
_level = value.ulVal;
|
||||
}
|
||||
else if (value.vt == VT_EMPTY)
|
||||
{
|
||||
if(!name.IsEmpty())
|
||||
{
|
||||
int index = ParseStringToUInt32(name, _level);
|
||||
if (index != name.Length())
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
if (_level == 0)
|
||||
{
|
||||
_copyMode = true;
|
||||
_defaultBZip2Passes = 1;
|
||||
}
|
||||
else if (_level < 5)
|
||||
{
|
||||
_defaultAlgorithm = kAlgorithmForFast;
|
||||
_defaultDicSize = kDicSizeForFast;
|
||||
_defaultMatchFinder = kMatchFinderForFast;
|
||||
_defaultBZip2Passes = 1;
|
||||
|
||||
_defaultPpmdMemSize = kPpmdMemSizeX1;
|
||||
_defaultPpmdOrder = kPpmdOrderX1;
|
||||
}
|
||||
else if (_level < 7)
|
||||
{
|
||||
_defaultBZip2Passes = 1;
|
||||
// normal;
|
||||
}
|
||||
else if(_level < 9)
|
||||
{
|
||||
_defaultAlgorithm = kAlgorithmForX7;
|
||||
_defaultDicSize = kDicSizeForX7;
|
||||
_defaultFastBytes = kFastBytesForX7;
|
||||
_defaultBZip2Passes = 2;
|
||||
|
||||
_defaultPpmdMemSize = kPpmdMemSizeX7;
|
||||
_defaultPpmdOrder = kPpmdOrderX7;
|
||||
|
||||
_defaultDeflateFastBytes = kDeflateFastBytesForX7;
|
||||
_defaultDeflatePasses = kDeflatePassesForX7;
|
||||
}
|
||||
else
|
||||
{
|
||||
_defaultAlgorithm = kAlgorithmForX9;
|
||||
_defaultDicSize = kDicSizeForX9;
|
||||
_defaultFastBytes = kFastBytesForX9;
|
||||
_defaultMatchFinder = kMatchFinderForX9;
|
||||
_defaultBZip2Passes = 7;
|
||||
|
||||
_defaultPpmdMemSize = kPpmdMemSizeX9;
|
||||
_defaultPpmdOrder = kPpmdOrderX9;
|
||||
|
||||
_defaultDeflateFastBytes = kDeflateFastBytesForX7;
|
||||
_defaultDeflatePasses = kDeflatePassesForX7;
|
||||
}
|
||||
RINOK(ParsePropValue(name, value, _level));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1090,7 +1016,14 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
UString realName = name.Mid(index);
|
||||
if (index == 0)
|
||||
{
|
||||
if (name.CompareNoCase(L"RSFX") == 0)
|
||||
if(name.Left(2).CompareNoCase(L"MT") == 0)
|
||||
{
|
||||
#ifdef COMPRESS_MT
|
||||
RINOK(ParseMtProp(name.Mid(2), value, numProcessors, _numThreads));
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
else if (name.CompareNoCase(L"RSFX") == 0)
|
||||
{
|
||||
RINOK(SetBoolProperty(_removeSfxBlock, value));
|
||||
continue;
|
||||
@@ -1115,13 +1048,6 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
RINOK(SetBoolProperty(_encryptHeaders, value));
|
||||
continue;
|
||||
}
|
||||
else if (name.CompareNoCase(L"MT") == 0)
|
||||
{
|
||||
// _multiThreadMult = 200;
|
||||
RINOK(SetBoolProperty(_multiThread, value));
|
||||
// RINOK(SetComplexProperty(MultiThread, _multiThreadMult, value));
|
||||
continue;
|
||||
}
|
||||
else if (name.CompareNoCase(L"V") == 0)
|
||||
{
|
||||
RINOK(SetBoolProperty(_volumeMode, value));
|
||||
@@ -1153,28 +1079,25 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
else
|
||||
{
|
||||
CProperty property;
|
||||
if (realName.CompareNoCase(L"D") == 0 || realName.CompareNoCase(L"MEM") == 0)
|
||||
if (realName.Left(1).CompareNoCase(L"D") == 0)
|
||||
{
|
||||
UInt32 dicSize;
|
||||
if (value.vt == VT_UI4)
|
||||
{
|
||||
UInt32 logDicSize = value.ulVal;
|
||||
if (logDicSize >= 32)
|
||||
return E_INVALIDARG;
|
||||
dicSize = (UInt32)1 << logDicSize;
|
||||
}
|
||||
else if (value.vt == VT_BSTR)
|
||||
{
|
||||
RINOK(ParseDictionaryValues(value.bstrVal, dicSize));
|
||||
}
|
||||
else
|
||||
return E_FAIL;
|
||||
if (realName.CompareNoCase(L"D") == 0)
|
||||
property.PropID = NCoderPropID::kDictionarySize;
|
||||
else
|
||||
property.PropID = NCoderPropID::kUsedMemorySize;
|
||||
RINOK(ParsePropDictionaryValue(realName.Mid(1), value, dicSize));
|
||||
property.PropID = NCoderPropID::kDictionarySize;
|
||||
property.Value = dicSize;
|
||||
oneMethodInfo.CoderProperties.Add(property);
|
||||
if (number <= mainDicMethodIndex)
|
||||
mainDicSize = dicSize;
|
||||
}
|
||||
else if (realName.Left(3).CompareNoCase(L"MEM") == 0)
|
||||
{
|
||||
UInt32 dicSize;
|
||||
RINOK(ParsePropDictionaryValue(realName.Mid(3), value, dicSize));
|
||||
property.PropID = NCoderPropID::kUsedMemorySize;
|
||||
property.Value = dicSize;
|
||||
oneMethodInfo.CoderProperties.Add(property);
|
||||
if (number <= mainDicMethodIndex)
|
||||
mainDicSize = dicSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1192,7 +1115,6 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckAndSetSolidBytesLimit();
|
||||
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
|
||||
@@ -880,6 +880,9 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(UInt64 baseOffset,
|
||||
#ifndef _NO_CRYPTO
|
||||
, getTextPassword
|
||||
#endif
|
||||
#ifdef COMPRESS_MT
|
||||
, false, 1
|
||||
#endif
|
||||
);
|
||||
RINOK(result);
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ struct CArchiveDatabaseEx: public CArchiveDatabase
|
||||
CNum folderIndex = FileIndexToFolderIndexMap[fileIndex];
|
||||
if (folderIndex >= 0)
|
||||
{
|
||||
const CFolder &folderInfo = Folders[folderIndex];
|
||||
if (FolderStartFileIndex[folderIndex] == fileIndex)
|
||||
return GetFolderFullPackSize(folderIndex);
|
||||
}
|
||||
@@ -244,7 +243,7 @@ private:
|
||||
CRecordVector<bool> &digestsDefined,
|
||||
CRecordVector<UInt32> &digests);
|
||||
|
||||
HRESULT CInArchive::ReadStreamsInfo(
|
||||
HRESULT ReadStreamsInfo(
|
||||
const CObjectVector<CByteBuffer> *dataVector,
|
||||
UInt64 &dataOffset,
|
||||
CRecordVector<UInt64> &packSizes,
|
||||
|
||||
@@ -73,11 +73,19 @@ static HRESULT WriteRange(IInStream *inStream,
|
||||
size, progress, currentComplexity);
|
||||
}
|
||||
|
||||
static int GetReverseSlashPos(const UString &name)
|
||||
{
|
||||
int slashPos = name.ReverseFind(L'/');
|
||||
#ifdef _WIN32
|
||||
int slash1Pos = name.ReverseFind(L'\\');
|
||||
slashPos = MyMax(slashPos, slash1Pos);
|
||||
#endif
|
||||
return slashPos;
|
||||
}
|
||||
|
||||
int CUpdateItem::GetExtensionPos() const
|
||||
{
|
||||
int slash1Pos = Name.ReverseFind(L'\\');
|
||||
int slash2Pos = Name.ReverseFind(L'/');
|
||||
int slashPos = MyMax(slash1Pos, slash2Pos);
|
||||
int slashPos = GetReverseSlashPos(Name);
|
||||
int dotPos = Name.ReverseFind(L'.');
|
||||
if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0))
|
||||
return Name.Length();
|
||||
@@ -220,9 +228,7 @@ struct CRefItem
|
||||
{
|
||||
if (sortByType)
|
||||
{
|
||||
int slash1Pos = updateItem.Name.ReverseFind(L'\\');
|
||||
int slash2Pos = updateItem.Name.ReverseFind(L'/');
|
||||
int slashPos = MyMax(slash1Pos, slash2Pos);
|
||||
int slashPos = GetReverseSlashPos(updateItem.Name);
|
||||
if (slashPos >= 0)
|
||||
NamePos = slashPos + 1;
|
||||
else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
PROG = 7z.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
7Z_OBJS = \
|
||||
@@ -61,6 +61,7 @@ AR_COMMON_OBJS = \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\MultiStream.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
|
||||
@@ -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 "BZIP2_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /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 "BZIP2_EXPORTS" /D "COMPRESS_MT" /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 "BZIP2_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /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 "BZIP2_EXPORTS" /D "COMPRESS_MT" /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"
|
||||
@@ -216,6 +216,14 @@ SOURCE=..\Common\DummyOutStream.cpp
|
||||
|
||||
SOURCE=..\Common\DummyOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Engine"
|
||||
|
||||
|
||||
@@ -191,6 +191,16 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
||||
decoder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
|
||||
if (setCoderMt)
|
||||
{
|
||||
RINOK(setCoderMt->SetNumberOfThreads(_numThreads));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
CDummyOutStream *outStreamSpec = new CDummyOutStream;
|
||||
CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#include "../IArchive.h"
|
||||
#include "BZip2Item.h"
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
namespace NArchive {
|
||||
namespace NBZip2 {
|
||||
|
||||
@@ -20,8 +24,21 @@ class CHandler:
|
||||
NArchive::NBZip2::CItem _item;
|
||||
UInt64 _streamStartPosition;
|
||||
|
||||
UInt32 _level;
|
||||
UInt32 _dicSize;
|
||||
UInt32 _numPasses;
|
||||
void InitMethodProperties() { _numPasses = 1; }
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 _numThreads;
|
||||
#endif
|
||||
void InitMethodProperties()
|
||||
{
|
||||
_level = 5;
|
||||
_dicSize =
|
||||
_numPasses = 0xFFFFFFFF;
|
||||
#ifdef COMPRESS_MT
|
||||
_numThreads = NWindows::NSystem::GetNumberOfProcessors();;
|
||||
#endif
|
||||
}
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP3(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// BZip2/OutHandler.cpp
|
||||
// BZip2HandlerOut.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
@@ -7,13 +7,23 @@
|
||||
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/String.h"
|
||||
#include "Common/StringToInt.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
|
||||
#include "../Common/ParseProperties.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
static const UInt32 kNumPassesX1 = 1;
|
||||
static const UInt32 kNumPassesX7 = 2;
|
||||
static const UInt32 kNumPassesX9 = 7;
|
||||
|
||||
static const UInt32 kDicSizeX1 = 100000;
|
||||
static const UInt32 kDicSizeX3 = 500000;
|
||||
static const UInt32 kDicSizeX5 = 900000;
|
||||
|
||||
namespace NArchive {
|
||||
namespace NBZip2 {
|
||||
|
||||
@@ -69,7 +79,24 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
return E_INVALIDARG;
|
||||
size = propVariant.uhVal.QuadPart;
|
||||
}
|
||||
return UpdateArchive(size, outStream, 0, _numPasses, updateCallback);
|
||||
|
||||
UInt32 dicSize = _dicSize;
|
||||
if (dicSize == 0xFFFFFFFF)
|
||||
dicSize = (_level >= 5 ? kDicSizeX5 :
|
||||
(_level >= 3 ? kDicSizeX3 :
|
||||
kDicSizeX1));
|
||||
|
||||
UInt32 numPasses = _numPasses;
|
||||
if (numPasses == 0xFFFFFFFF)
|
||||
numPasses = (_level >= 9 ? kNumPassesX9 :
|
||||
(_level >= 7 ? kNumPassesX7 :
|
||||
kNumPassesX1));
|
||||
|
||||
return UpdateArchive(size, outStream, 0, dicSize, numPasses,
|
||||
#ifdef COMPRESS_MT
|
||||
_numThreads,
|
||||
#endif
|
||||
updateCallback);
|
||||
}
|
||||
if (indexInArchive != 0)
|
||||
return E_INVALIDARG;
|
||||
@@ -80,6 +107,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
|
||||
{
|
||||
InitMethodProperties();
|
||||
#ifdef COMPRESS_MT
|
||||
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
|
||||
_numThreads = numProcessors;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < numProperties; i++)
|
||||
{
|
||||
UString name = UString(names[i]);
|
||||
@@ -87,68 +119,34 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
if (name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
|
||||
const PROPVARIANT &value = values[i];
|
||||
const PROPVARIANT &prop = values[i];
|
||||
|
||||
if (name[0] == 'X')
|
||||
{
|
||||
name.Delete(0);
|
||||
UInt32 level = 9;
|
||||
if (value.vt == VT_UI4)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
level = value.ulVal;
|
||||
}
|
||||
else if (value.vt == VT_EMPTY)
|
||||
{
|
||||
if(!name.IsEmpty())
|
||||
{
|
||||
const wchar_t *start = name;
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(start, &end);
|
||||
if (end - start != name.Length())
|
||||
return E_INVALIDARG;
|
||||
level = (UInt32)v;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
if (level < 7)
|
||||
_numPasses = 1;
|
||||
else if (level < 9)
|
||||
_numPasses = 2;
|
||||
else
|
||||
_numPasses = 7;
|
||||
RINOK(ParsePropValue(name.Mid(1), prop, level));
|
||||
_level = level;
|
||||
continue;
|
||||
}
|
||||
else if (name.Left(4) == L"PASS")
|
||||
if (name[0] == 'D')
|
||||
{
|
||||
name.Delete(0, 4);
|
||||
UInt32 numPasses = 1;
|
||||
if (value.vt == VT_UI4)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
numPasses = value.ulVal;
|
||||
}
|
||||
else if (value.vt == VT_EMPTY)
|
||||
{
|
||||
if(!name.IsEmpty())
|
||||
{
|
||||
const wchar_t *start = name;
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(start, &end);
|
||||
if (end - start != name.Length())
|
||||
return E_INVALIDARG;
|
||||
numPasses = (UInt32)v;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (numPasses < 1 || numPasses > 10)
|
||||
return E_INVALIDARG;
|
||||
_numPasses = numPasses;
|
||||
UInt32 dicSize = kDicSizeX5;
|
||||
RINOK(ParsePropDictionaryValue(name.Mid(1), prop, dicSize));
|
||||
_dicSize = dicSize;
|
||||
continue;
|
||||
}
|
||||
if (name.Left(4) == L"PASS")
|
||||
{
|
||||
UInt32 num = kNumPassesX9;
|
||||
RINOK(ParsePropValue(name.Mid(4), prop, num));
|
||||
_numPasses = num;
|
||||
continue;
|
||||
}
|
||||
if (name.Left(2) == L"MT")
|
||||
{
|
||||
#ifdef COMPRESS_MT
|
||||
RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads));
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
return E_INVALIDARG;
|
||||
|
||||
@@ -23,7 +23,11 @@ namespace NBZip2 {
|
||||
HRESULT UpdateArchive(UInt64 unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
int indexInClient,
|
||||
UInt32 dictionary,
|
||||
UInt32 numPasses,
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 numThreads,
|
||||
#endif
|
||||
IArchiveUpdateCallback *updateCallback)
|
||||
{
|
||||
RINOK(updateCallback->SetTotal(unpackSize));
|
||||
@@ -53,21 +57,23 @@ HRESULT UpdateArchive(UInt64 unpackSize,
|
||||
encoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties);
|
||||
if (setCoderProperties)
|
||||
{
|
||||
/*
|
||||
NWindows::NCOM::CPropVariant properties[2] =
|
||||
NWindows::NCOM::CPropVariant properties[] =
|
||||
{
|
||||
dictionary, numPasses
|
||||
dictionary,
|
||||
numPasses
|
||||
#ifdef COMPRESS_MT
|
||||
, numThreads
|
||||
#endif
|
||||
};
|
||||
PROPID propIDs[2] =
|
||||
PROPID propIDs[] =
|
||||
{
|
||||
NCoderPropID::kDictionarySize,
|
||||
NCoderPropID::kNumPasses,
|
||||
NCoderPropID::kNumPasses
|
||||
#ifdef COMPRESS_MT
|
||||
, NCoderPropID::kNumThreads
|
||||
#endif
|
||||
};
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, 2));
|
||||
*/
|
||||
NWindows::NCOM::CPropVariant property = numPasses;
|
||||
PROPID propID = NCoderPropID::kNumPasses;
|
||||
RINOK(setCoderProperties->SetCoderProperties(&propID, &property, 1));
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, sizeof(propIDs) / sizeof(propIDs[0])));
|
||||
}
|
||||
|
||||
RINOK(encoder->Code(fileInStream, outStream, NULL, NULL, localProgress));
|
||||
|
||||
@@ -12,7 +12,11 @@ HRESULT UpdateArchive(
|
||||
UInt64 unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
int indexInClient,
|
||||
UInt32 dictionary,
|
||||
UInt32 numPasses,
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 numThreads,
|
||||
#endif
|
||||
IArchiveUpdateCallback *updateCallback);
|
||||
|
||||
}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
PROG = bz2.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
BZ2_OBJS = \
|
||||
@@ -27,6 +27,7 @@ WIN_OBJS = \
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CodecsPath.obj \
|
||||
$O\DummyOutStream.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "../../Compress/Lzx/LzxDecoder.h"
|
||||
#include "../../Compress/Quantum/QuantumDecoder.h"
|
||||
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
@@ -117,17 +119,15 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
UString unicodeName;
|
||||
if (item.IsNameUTF())
|
||||
{
|
||||
UString unicodeName;
|
||||
if (!ConvertUTF8ToUnicode(item.Name, unicodeName))
|
||||
propVariant = L"";
|
||||
else
|
||||
propVariant = unicodeName;
|
||||
}
|
||||
ConvertUTF8ToUnicode(item.Name, unicodeName);
|
||||
else
|
||||
propVariant = MultiByteToUnicodeString(item.Name, CP_ACP);
|
||||
unicodeName = MultiByteToUnicodeString(item.Name, CP_ACP);
|
||||
propVariant = (const wchar_t *)NItemName::WinNameToOSName(unicodeName);
|
||||
break;
|
||||
}
|
||||
case kpidIsFolder:
|
||||
propVariant = item.IsDirectory();
|
||||
break;
|
||||
|
||||
@@ -42,4 +42,4 @@ private:
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -16,4 +16,4 @@ static class CSignatureInitializer
|
||||
|
||||
}
|
||||
|
||||
}}}
|
||||
}}}
|
||||
|
||||
@@ -43,4 +43,4 @@ private:
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -15,7 +15,7 @@ static CSysString GetLibraryPath()
|
||||
static CSysString GetLibraryFolderPrefix()
|
||||
{
|
||||
CSysString path = GetLibraryPath();
|
||||
int pos = path.ReverseFind(TEXT('\\'));
|
||||
int pos = path.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
|
||||
return path.Left(pos + 1);
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ CSysString GetBaseFolderPrefix()
|
||||
CSysString libPrefix = GetLibraryFolderPrefix();
|
||||
CSysString temp = libPrefix;
|
||||
temp.Delete(temp.Length() - 1);
|
||||
int pos = temp.ReverseFind(TEXT('\\'));
|
||||
int pos = temp.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
|
||||
return temp.Left(pos + 1);
|
||||
}
|
||||
|
||||
CSysString GetCodecsFolderPrefix()
|
||||
{
|
||||
return GetBaseFolderPrefix() + TEXT("Codecs\\");
|
||||
return GetBaseFolderPrefix() + (CSysString)(TEXT("Codecs")) + (CSysString)(TEXT(STRING_PATH_SEPARATOR));
|
||||
}
|
||||
|
||||
@@ -229,7 +229,6 @@ STDMETHODIMP CCoderMixer2MT::Init(ISequentialInStream **inStreams,
|
||||
{
|
||||
if (_coderInfoVector.Size() != _bindInfo.Coders.Size())
|
||||
throw 0;
|
||||
UInt32 numInStreams = 0, numOutStreams = 0;
|
||||
int i;
|
||||
for(i = 0; i < _coderInfoVector.Size(); i++)
|
||||
{
|
||||
|
||||
@@ -200,7 +200,13 @@ STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
_convertedPosEnd = Filter->Filter(_buffer, _bufferPos);
|
||||
if (_convertedPosEnd == 0)
|
||||
{
|
||||
break;
|
||||
if (_bufferPos == 0)
|
||||
break;
|
||||
else
|
||||
{
|
||||
_convertedPosEnd = _bufferPos; // check it
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (_convertedPosEnd > _bufferPos)
|
||||
{
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
namespace NArchive {
|
||||
namespace NItemName {
|
||||
|
||||
static const wchar_t kOSDirDelimiter = '\\';
|
||||
static const wchar_t kDirDelimiter = '/';
|
||||
static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR;
|
||||
static const wchar_t kDirDelimiter = L'/';
|
||||
|
||||
UString MakeLegalName(const UString &name)
|
||||
{
|
||||
@@ -47,4 +47,13 @@ bool HasTailSlash(const AString &name, UINT codePage)
|
||||
return (*prev == '/');
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
UString WinNameToOSName(const UString &name)
|
||||
{
|
||||
UString newName = name;
|
||||
newName.Replace(L'\\', kOSDirDelimiter);
|
||||
return newName;
|
||||
}
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
@@ -13,6 +13,12 @@ namespace NItemName {
|
||||
UString GetOSName2(const UString &name);
|
||||
bool HasTailSlash(const AString &name, UINT codePage);
|
||||
|
||||
#ifdef _WIN32
|
||||
inline UString WinNameToOSName(const UString &name) { return name; }
|
||||
#else
|
||||
UString WinNameToOSName(const UString &name);
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
171
7zip/Archive/Common/ParseProperties.cpp
Executable file
171
7zip/Archive/Common/ParseProperties.cpp
Executable file
@@ -0,0 +1,171 @@
|
||||
// ParseProperties.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ParseProperties.h"
|
||||
|
||||
#include "Common/StringToInt.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
HRESULT ParsePropValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue)
|
||||
{
|
||||
if (prop.vt == VT_UI4)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
resValue = prop.ulVal;
|
||||
}
|
||||
else if (prop.vt == VT_EMPTY)
|
||||
{
|
||||
if(!name.IsEmpty())
|
||||
{
|
||||
const wchar_t *start = name;
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(start, &end);
|
||||
if (end - start != name.Length())
|
||||
return E_INVALIDARG;
|
||||
resValue = (UInt32)v;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const int kLogarithmicSizeLimit = 32;
|
||||
static const wchar_t kByteSymbol = L'B';
|
||||
static const wchar_t kKiloByteSymbol = L'K';
|
||||
static const wchar_t kMegaByteSymbol = L'M';
|
||||
|
||||
HRESULT ParsePropDictionaryValue(const UString &srcStringSpec, UInt32 &dicSize)
|
||||
{
|
||||
UString srcString = srcStringSpec;
|
||||
srcString.MakeUpper();
|
||||
|
||||
const wchar_t *start = srcString;
|
||||
const wchar_t *end;
|
||||
UInt64 number = ConvertStringToUInt64(start, &end);
|
||||
int numDigits = (int)(end - start);
|
||||
if (numDigits == 0 || srcString.Length() > numDigits + 1)
|
||||
return E_INVALIDARG;
|
||||
if (srcString.Length() == numDigits)
|
||||
{
|
||||
if (number >= kLogarithmicSizeLimit)
|
||||
return E_INVALIDARG;
|
||||
dicSize = (UInt32)1 << (int)number;
|
||||
return S_OK;
|
||||
}
|
||||
switch (srcString[numDigits])
|
||||
{
|
||||
case kByteSymbol:
|
||||
if (number >= ((UInt64)1 << kLogarithmicSizeLimit))
|
||||
return E_INVALIDARG;
|
||||
dicSize = (UInt32)number;
|
||||
break;
|
||||
case kKiloByteSymbol:
|
||||
if (number >= ((UInt64)1 << (kLogarithmicSizeLimit - 10)))
|
||||
return E_INVALIDARG;
|
||||
dicSize = (UInt32)(number << 10);
|
||||
break;
|
||||
case kMegaByteSymbol:
|
||||
if (number >= ((UInt64)1 << (kLogarithmicSizeLimit - 20)))
|
||||
return E_INVALIDARG;
|
||||
dicSize = (UInt32)(number << 20);
|
||||
break;
|
||||
default:
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT ParsePropDictionaryValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue)
|
||||
{
|
||||
if (name.IsEmpty())
|
||||
{
|
||||
if (prop.vt == VT_UI4)
|
||||
{
|
||||
UInt32 logDicSize = prop.ulVal;
|
||||
if (logDicSize >= 32)
|
||||
return E_INVALIDARG;
|
||||
resValue = (UInt32)1 << logDicSize;
|
||||
return S_OK;
|
||||
}
|
||||
if (prop.vt == VT_BSTR)
|
||||
return ParsePropDictionaryValue(prop.bstrVal, resValue);
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return ParsePropDictionaryValue(name, resValue);
|
||||
}
|
||||
|
||||
HRESULT SetBoolProperty(bool &dest, const PROPVARIANT &value)
|
||||
{
|
||||
switch(value.vt)
|
||||
{
|
||||
case VT_EMPTY:
|
||||
dest = true;
|
||||
break;
|
||||
/*
|
||||
case VT_UI4:
|
||||
dest = (value.ulVal != 0);
|
||||
break;
|
||||
*/
|
||||
case VT_BSTR:
|
||||
{
|
||||
UString valueString = value.bstrVal;
|
||||
valueString.MakeUpper();
|
||||
if (valueString.Compare(L"ON") == 0)
|
||||
dest = true;
|
||||
else if (valueString.Compare(L"OFF") == 0)
|
||||
dest = false;
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int ParseStringToUInt32(const UString &srcString, UInt32 &number)
|
||||
{
|
||||
const wchar_t *start = srcString;
|
||||
const wchar_t *end;
|
||||
UInt64 number64 = ConvertStringToUInt64(start, &end);
|
||||
if (number64 > 0xFFFFFFFF)
|
||||
{
|
||||
number = 0;
|
||||
return 0;
|
||||
}
|
||||
number = (UInt32)number64;
|
||||
return (int)(end - start);
|
||||
}
|
||||
|
||||
HRESULT ParseMtProp(const UString &name, const PROPVARIANT &prop, UInt32 defaultNumThreads, UInt32 &numThreads)
|
||||
{
|
||||
if (name.IsEmpty())
|
||||
{
|
||||
switch(prop.vt)
|
||||
{
|
||||
case VT_UI4:
|
||||
numThreads = prop.ulVal;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
bool val;
|
||||
RINOK(SetBoolProperty(val, prop));
|
||||
numThreads = (val ? defaultNumThreads : 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt32 number;
|
||||
int index = ParseStringToUInt32(name, number);
|
||||
if (index != name.Length())
|
||||
return E_INVALIDARG;
|
||||
numThreads = number;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
17
7zip/Archive/Common/ParseProperties.h
Executable file
17
7zip/Archive/Common/ParseProperties.h
Executable file
@@ -0,0 +1,17 @@
|
||||
// ParseProperties.h
|
||||
|
||||
#ifndef __PARSEPROPERTIES_H
|
||||
#define __PARSEPROPERTIES_H
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "Common/Types.h"
|
||||
|
||||
HRESULT ParsePropValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue);
|
||||
HRESULT ParsePropDictionaryValue(const UString &srcStringSpec, UInt32 &dicSize);
|
||||
HRESULT ParsePropDictionaryValue(const UString &name, const PROPVARIANT &prop, UInt32 &resValue);
|
||||
|
||||
HRESULT SetBoolProperty(bool &dest, const PROPVARIANT &value);
|
||||
int ParseStringToUInt32(const UString &srcString, UInt32 &number);
|
||||
HRESULT ParseMtProp(const UString &name, const PROPVARIANT &prop, UInt32 defaultNumThreads, UInt32 &numThreads);
|
||||
|
||||
#endif
|
||||
@@ -44,4 +44,4 @@ private:
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -304,6 +304,14 @@ SOURCE=..\Common\OutStreamWithCRC.cpp
|
||||
|
||||
SOURCE=..\Common\OutStreamWithCRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
|
||||
outStreamSpec->InitCRC();
|
||||
|
||||
switch(m_Item.CompressionMethod)
|
||||
switch(item.CompressionMethod)
|
||||
{
|
||||
case NFileHeader::NCompressionMethod::kDeflate:
|
||||
{
|
||||
|
||||
@@ -65,10 +65,12 @@ private:
|
||||
UInt64 m_PackSize;
|
||||
CMyComPtr<IInStream> m_Stream;
|
||||
CCompressionMethodMode m_Method;
|
||||
UInt32 m_Level;
|
||||
|
||||
void InitMethodProperties()
|
||||
{
|
||||
m_Method.NumPasses = 1;
|
||||
m_Method.NumFastBytes = 32;
|
||||
m_Method.NumMatchFinderCyclesDefined = false;
|
||||
m_Level = m_Method.NumPasses = m_Method.NumFastBytes = m_Method.NumMatchFinderCycles = 0xFFFFFFFF;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
#include "../Common/ParseProperties.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NTime;
|
||||
@@ -20,6 +21,15 @@ using namespace NTime;
|
||||
namespace NArchive {
|
||||
namespace NGZip {
|
||||
|
||||
static const UInt32 kNumPassesX1 = 1;
|
||||
static const UInt32 kNumPassesX7 = 3;
|
||||
static const UInt32 kNumPassesX9 = 10;
|
||||
|
||||
static const UInt32 kNumFastBytesX1 = 32;
|
||||
static const UInt32 kNumFastBytesX7 = 64;
|
||||
static const UInt32 kNumFastBytesX9 = 128;
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetFileTimeType(UInt32 *timeType)
|
||||
{
|
||||
*timeType = NFileTimeType::kUnix;
|
||||
@@ -100,7 +110,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
if(!FileTimeToUnixTime(utcTime, newItem.Time))
|
||||
return E_INVALIDARG;
|
||||
newItem.Name = UnicodeStringToMultiByte(name, CP_ACP);
|
||||
int dirDelimiterPos = newItem.Name.ReverseFind('\\');
|
||||
int dirDelimiterPos = newItem.Name.ReverseFind(CHAR_PATH_SEPARATOR);
|
||||
if (dirDelimiterPos >= 0)
|
||||
newItem.Name = newItem.Name.Mid(dirDelimiterPos + 1);
|
||||
|
||||
@@ -117,8 +127,20 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
size = propVariant.uhVal.QuadPart;
|
||||
}
|
||||
newItem.UnPackSize32 = (UInt32)size;
|
||||
return UpdateArchive(m_Stream, size, outStream, newItem,
|
||||
m_Method, itemIndex, updateCallback);
|
||||
|
||||
UInt32 level = m_Level;
|
||||
if (level == 0xFFFFFFFF)
|
||||
level = 5;
|
||||
if (m_Method.NumPasses == 0xFFFFFFFF)
|
||||
m_Method.NumPasses = (level >= 9 ? kNumPassesX9 :
|
||||
(level >= 7 ? kNumPassesX7 :
|
||||
kNumPassesX1));
|
||||
if (m_Method.NumFastBytes == 0xFFFFFFFF)
|
||||
m_Method.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
|
||||
(level >= 7 ? kNumFastBytesX7 :
|
||||
kNumFastBytesX1));
|
||||
|
||||
return UpdateArchive(m_Stream, size, outStream, newItem, m_Method, itemIndex, updateCallback);
|
||||
}
|
||||
|
||||
if (indexInArchive != 0)
|
||||
@@ -138,72 +160,38 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
return CopyStreams(m_Stream, outStream, updateCallback);
|
||||
}
|
||||
|
||||
static const UInt32 kMatchFastLenNormal = 32;
|
||||
static const UInt32 kMatchFastLenMX = 64;
|
||||
|
||||
static const UInt32 kNumPassesNormal = 1;
|
||||
static const UInt32 kNumPassesMX = 3;
|
||||
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
|
||||
{
|
||||
InitMethodProperties();
|
||||
for (int i = 0; i < numProperties; i++)
|
||||
{
|
||||
UString name = UString(names[i]);
|
||||
UString name = names[i];
|
||||
name.MakeUpper();
|
||||
const PROPVARIANT &value = values[i];
|
||||
if (name[0] == 'X')
|
||||
const PROPVARIANT &prop = values[i];
|
||||
if (name[0] == L'X')
|
||||
{
|
||||
name.Delete(0);
|
||||
UInt32 level = 9;
|
||||
if (value.vt == VT_UI4)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
level = value.ulVal;
|
||||
}
|
||||
else if (value.vt == VT_EMPTY)
|
||||
{
|
||||
if(!name.IsEmpty())
|
||||
{
|
||||
const wchar_t *start = name;
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(start, &end);
|
||||
if (end - start != name.Length())
|
||||
return E_INVALIDARG;
|
||||
level = (UInt32)v;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
if (level < 7)
|
||||
{
|
||||
InitMethodProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Method.NumPasses = kNumPassesMX;
|
||||
m_Method.NumFastBytes = kMatchFastLenMX;
|
||||
}
|
||||
continue;
|
||||
RINOK(ParsePropValue(name.Mid(1), prop, level));
|
||||
m_Level = level;
|
||||
}
|
||||
else if (name == L"PASS")
|
||||
else if (name.Left(4) == L"PASS")
|
||||
{
|
||||
if (value.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
m_Method.NumPasses = value.ulVal;
|
||||
if (m_Method.NumPasses < 1 || m_Method.NumPasses > 10)
|
||||
return E_INVALIDARG;
|
||||
UInt32 num = kNumPassesX9;
|
||||
RINOK(ParsePropValue(name.Mid(4), prop, num));
|
||||
m_Method.NumPasses = num;
|
||||
}
|
||||
else if (name == L"FB")
|
||||
else if (name.Left(2) == L"FB")
|
||||
{
|
||||
if (value.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
m_Method.NumFastBytes = value.ulVal;
|
||||
/*
|
||||
if (m_Method.NumFastBytes < 3 || m_Method.NumFastBytes > 255)
|
||||
return E_INVALIDARG;
|
||||
*/
|
||||
UInt32 num = kNumFastBytesX9;
|
||||
RINOK(ParsePropValue(name.Mid(2), prop, num));
|
||||
m_Method.NumFastBytes = num;
|
||||
}
|
||||
else if (name.Left(2) == L"MC")
|
||||
{
|
||||
UInt32 num = 0xFFFFFFFF;
|
||||
RINOK(ParsePropValue(name.Mid(2), prop, num));
|
||||
m_Method.NumMatchFinderCycles = num;
|
||||
m_Method.NumMatchFinderCyclesDefined = true;
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
|
||||
@@ -89,14 +89,24 @@ HRESULT UpdateArchive(IInStream *inStream,
|
||||
CLSID_CCompressDeflateEncoder, &deflateEncoder));
|
||||
#endif
|
||||
|
||||
NWindows::NCOM::CPropVariant properties[2] =
|
||||
{ compressionMethod.NumPasses, compressionMethod.NumFastBytes };
|
||||
PROPID propIDs[2] =
|
||||
{ NCoderPropID::kNumPasses, NCoderPropID::kNumFastBytes };
|
||||
NWindows::NCOM::CPropVariant properties[] =
|
||||
{
|
||||
compressionMethod.NumPasses,
|
||||
compressionMethod.NumFastBytes,
|
||||
compressionMethod.NumMatchFinderCycles
|
||||
};
|
||||
PROPID propIDs[] =
|
||||
{
|
||||
NCoderPropID::kNumPasses,
|
||||
NCoderPropID::kNumFastBytes,
|
||||
NCoderPropID::kMatchFinderCycles
|
||||
};
|
||||
int numProps = sizeof(propIDs) / sizeof(propIDs[0]);
|
||||
if (!compressionMethod.NumMatchFinderCyclesDefined)
|
||||
numProps--;
|
||||
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
|
||||
RINOK(deflateEncoder.QueryInterface(
|
||||
IID_ICompressSetCoderProperties, &setCoderProperties));
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, 2));
|
||||
RINOK(deflateEncoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties));
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, numProps));
|
||||
}
|
||||
RINOK(deflateEncoder->Code(crcStream, outStream, NULL, NULL, compressProgress));
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ struct CCompressionMethodMode
|
||||
{
|
||||
UInt32 NumPasses;
|
||||
UInt32 NumFastBytes;
|
||||
bool NumMatchFinderCyclesDefined;
|
||||
UInt32 NumMatchFinderCycles;
|
||||
};
|
||||
|
||||
HRESULT UpdateArchive(IInStream *inStream,
|
||||
|
||||
@@ -32,6 +32,7 @@ AR_COMMON_OBJS = \
|
||||
$O\CodecsPath.obj \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
|
||||
88
7zip/Archive/Iso/DllExports.cpp
Executable file
88
7zip/Archive/Iso/DllExports.cpp
Executable file
@@ -0,0 +1,88 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "../../ICoder.h"
|
||||
#include "IsoHandler.h"
|
||||
|
||||
// {23170F69-40C1-278A-1000-000110E70000}
|
||||
DEFINE_GUID(CLSID_CIsoHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE7, 0x00, 0x00);
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID != CLSID_CIsoHandler)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
int needIn = *interfaceID == IID_IInArchive;
|
||||
// int needOut = *interfaceID == IID_IOutArchive;
|
||||
if (needIn /*|| needOut */)
|
||||
{
|
||||
NArchive::NIso::CHandler *temp = new NArchive::NIso::CHandler;
|
||||
if (needIn)
|
||||
{
|
||||
CMyComPtr<IInArchive> inArchive = (IInArchive *)temp;
|
||||
*outObject = inArchive.Detach();
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
CMyComPtr<IOutArchive> outArchive = (IOutArchive *)temp;
|
||||
*outObject = outArchive.Detach();
|
||||
}
|
||||
*/
|
||||
}
|
||||
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"Iso";
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CIsoHandler, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"iso";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kKeepName:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
const unsigned char sig[] = { 'C', 'D', '0', '0', '1', 0x1 };
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen((const char *)sig, 7)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
273
7zip/Archive/Iso/Iso.dsp
Executable file
273
7zip/Archive/Iso/Iso.dsp
Executable file
@@ -0,0 +1,273 @@
|
||||
# Microsoft Developer Studio Project File - Name="Iso" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Iso - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Iso.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Iso.mak" CFG="Iso - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Iso - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Iso - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Iso - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# 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 "TAR_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /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"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Formats\Iso.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Iso - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# 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 "TAR_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /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"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Formats\Iso.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Iso - Win32 Release"
|
||||
# Name "Iso - Win32 Debug"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Archive.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Iso.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"StdAfx.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# 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
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Engine"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IsoHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IsoHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IsoHeader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IsoHeader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IsoIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IsoIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IsoItem.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ItemNameUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
7zip/Archive/Iso/Iso.dsw
Executable file
29
7zip/Archive/Iso/Iso.dsw
Executable file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Iso"=.\Iso.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
BIN
7zip/Archive/Iso/Iso.ico
Executable file
BIN
7zip/Archive/Iso/Iso.ico
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
301
7zip/Archive/Iso/IsoHandler.cpp
Executable file
301
7zip/Archive/Iso/IsoHandler.cpp
Executable file
@@ -0,0 +1,301 @@
|
||||
// Iso/Handler.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "IsoHandler.h"
|
||||
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/NewHandler.h"
|
||||
#include "Common/ComTry.h"
|
||||
|
||||
#include "Windows/Time.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NTime;
|
||||
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
STATPROPSTG kProperties[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidIsFolder, VT_BOOL},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidPackedSize, VT_UI8},
|
||||
{ NULL, kpidLastWriteTime, VT_FILETIME}
|
||||
};
|
||||
|
||||
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
value->vt = VT_EMPTY;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
|
||||
return E_INVALIDARG;
|
||||
const STATPROPSTG &srcItem = kProperties[index];
|
||||
*propID = srcItem.propid;
|
||||
*varType = srcItem.vt;
|
||||
*name = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
IArchiveOpenCallback *openArchiveCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
bool mustBeClosed = true;
|
||||
Close();
|
||||
// try
|
||||
{
|
||||
if(_archive.Open(stream) != S_OK)
|
||||
return S_FALSE;
|
||||
_inStream = stream;
|
||||
}
|
||||
// catch(...) { return S_FALSE; }
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_archive.Clear();
|
||||
_inStream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = _archive.Refs.Size() + _archive.BootEntries.Size();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
if (index >= (UInt32)_archive.Refs.Size())
|
||||
{
|
||||
index -= _archive.Refs.Size();
|
||||
const CBootInitialEntry &be = _archive.BootEntries[index];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
// wchar_t name[32];
|
||||
// ConvertUInt64ToString(index + 1, name);
|
||||
UString s = L"[BOOT]" WSTRING_PATH_SEPARATOR;
|
||||
// s += name;
|
||||
// s += L"-";
|
||||
s += be.GetName();
|
||||
propVariant = (const wchar_t *)s;
|
||||
break;
|
||||
}
|
||||
case kpidIsFolder:
|
||||
propVariant = false;
|
||||
break;
|
||||
case kpidSize:
|
||||
case kpidPackedSize:
|
||||
{
|
||||
propVariant = (UInt64)_archive.GetBootItemSize(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const CRef &ref = _archive.Refs[index];
|
||||
const CDir &item = ref.Dir->_subItems[ref.Index];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
if (item.FileId.GetCapacity() >= 0)
|
||||
{
|
||||
UString s;
|
||||
if (_archive.IsJoliet())
|
||||
s = item.GetPathU();
|
||||
else
|
||||
s = MultiByteToUnicodeString(item.GetPath(_archive.IsSusp, _archive.SuspSkipSize), CP_OEMCP);
|
||||
|
||||
int pos = s.ReverseFind(L';');
|
||||
if (pos >= 0 && pos == s.Length() - 2)
|
||||
if (s[s.Length() - 1] == L'1')
|
||||
s = s.Left(pos);
|
||||
if (!s.IsEmpty())
|
||||
if (s[s.Length() - 1] == L'.')
|
||||
s = s.Left(s.Length() - 1);
|
||||
propVariant = (const wchar_t *)NItemName::GetOSName2(s);
|
||||
}
|
||||
break;
|
||||
case kpidIsFolder:
|
||||
propVariant = item.IsDir();
|
||||
break;
|
||||
case kpidSize:
|
||||
case kpidPackedSize:
|
||||
if (!item.IsDir())
|
||||
propVariant = (UInt64)item.DataLength;
|
||||
break;
|
||||
case kpidLastWriteTime:
|
||||
{
|
||||
FILETIME utcFileTime;
|
||||
if (item.DateTime.GetFileTime(utcFileTime))
|
||||
propVariant = utcFileTime;
|
||||
/*
|
||||
else
|
||||
{
|
||||
utcFileTime.dwLowDateTime = 0;
|
||||
utcFileTime.dwHighDateTime = 0;
|
||||
}
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
bool testMode = (_aTestMode != 0);
|
||||
bool allFilesMode = (numItems == UInt32(-1));
|
||||
if (allFilesMode)
|
||||
numItems = _archive.Refs.Size();
|
||||
UInt64 totalSize = 0;
|
||||
if(numItems == 0)
|
||||
return S_OK;
|
||||
UInt32 i;
|
||||
for(i = 0; i < numItems; i++)
|
||||
{
|
||||
UInt32 index = (allFilesMode ? i : indices[i]);
|
||||
if (index < (UInt32)_archive.Refs.Size())
|
||||
{
|
||||
const CRef &ref = _archive.Refs[index];
|
||||
const CDir &item = ref.Dir->_subItems[ref.Index];
|
||||
totalSize += item.DataLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
totalSize += _archive.GetBootItemSize(index - _archive.Refs.Size());
|
||||
}
|
||||
}
|
||||
extractCallback->SetTotal(totalSize);
|
||||
|
||||
UInt64 currentTotalSize = 0;
|
||||
UInt64 currentItemSize;
|
||||
|
||||
CMyComPtr<ICompressCoder> copyCoder;
|
||||
|
||||
for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
|
||||
{
|
||||
currentItemSize = 0;
|
||||
RINOK(extractCallback->SetCompleted(¤tTotalSize));
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
Int32 askMode;
|
||||
askMode = testMode ? NArchive::NExtract::NAskMode::kTest : NArchive::NExtract::NAskMode::kExtract;
|
||||
UInt32 index = allFilesMode ? i : indices[i];
|
||||
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
||||
|
||||
UInt64 blockIndex;
|
||||
if (index < (UInt32)_archive.Refs.Size())
|
||||
{
|
||||
const CRef &ref = _archive.Refs[index];
|
||||
const CDir &item = ref.Dir->_subItems[ref.Index];
|
||||
if(item.IsDir())
|
||||
{
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
|
||||
continue;
|
||||
}
|
||||
currentItemSize = item.DataLength;
|
||||
blockIndex = item.ExtentLocation;
|
||||
}
|
||||
else
|
||||
{
|
||||
int bootIndex = index - _archive.Refs.Size();
|
||||
const CBootInitialEntry &be = _archive.BootEntries[bootIndex];
|
||||
currentItemSize = _archive.GetBootItemSize(bootIndex);
|
||||
blockIndex = be.LoadRBA;
|
||||
}
|
||||
|
||||
if(!testMode && (!realOutStream))
|
||||
continue;
|
||||
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
{
|
||||
if (testMode)
|
||||
{
|
||||
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
|
||||
continue;
|
||||
}
|
||||
|
||||
RINOK(_inStream->Seek(blockIndex * _archive.BlockSize, STREAM_SEEK_SET, NULL));
|
||||
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
|
||||
CMyComPtr<ISequentialInStream> inStream(streamSpec);
|
||||
streamSpec->Init(_inStream, currentItemSize);
|
||||
|
||||
CLocalProgress *localProgressSpec = new CLocalProgress;
|
||||
CMyComPtr<ICompressProgressInfo> progress = localProgressSpec;
|
||||
localProgressSpec->Init(extractCallback, false);
|
||||
|
||||
CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
|
||||
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
|
||||
localCompressProgressSpec->Init(progress, ¤tTotalSize, ¤tTotalSize);
|
||||
|
||||
Int32 res = NArchive::NExtract::NOperationResult::kOK;
|
||||
if(!copyCoder)
|
||||
{
|
||||
copyCoder = new NCompress::CCopyCoder;
|
||||
}
|
||||
try
|
||||
{
|
||||
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, compressProgress));
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
res = NArchive::NExtract::NOperationResult::kDataError;
|
||||
}
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(res));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
}}
|
||||
59
7zip/Archive/Iso/IsoHandler.h
Executable file
59
7zip/Archive/Iso/IsoHandler.h
Executable file
@@ -0,0 +1,59 @@
|
||||
// Tar/Handler.h
|
||||
|
||||
#ifndef __ISO_HANDLER_H
|
||||
#define __ISO_HANDLER_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "../IArchive.h"
|
||||
|
||||
#include "IsoItem.h"
|
||||
#include "IsoIn.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
class CHandler:
|
||||
public IInArchive,
|
||||
// public IOutArchive,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(
|
||||
IInArchive
|
||||
// IOutArchive
|
||||
)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
IArchiveOpenCallback *openArchiveCallback);
|
||||
STDMETHOD(Close)();
|
||||
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
|
||||
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
|
||||
Int32 testMode, IArchiveExtractCallback *extractCallback);
|
||||
|
||||
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
|
||||
|
||||
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
|
||||
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
|
||||
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
|
||||
BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
|
||||
/*
|
||||
// IOutArchive
|
||||
STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems,
|
||||
IArchiveUpdateCallback *updateCallback);
|
||||
STDMETHOD(GetFileTimeType)(UInt32 *type);
|
||||
*/
|
||||
|
||||
private:
|
||||
CMyComPtr<IInStream> _inStream;
|
||||
CInArchive _archive;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
21
7zip/Archive/Iso/IsoHeader.cpp
Executable file
21
7zip/Archive/Iso/IsoHeader.cpp
Executable file
@@ -0,0 +1,21 @@
|
||||
// Archive/Iso/Header.h
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "IsoHeader.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
const char *kElToritoSpec = "EL TORITO SPECIFICATION\0\0\0\0\0\0\0\0\0";
|
||||
|
||||
const wchar_t *kMediaTypes[5] =
|
||||
{
|
||||
L"NoEmulation",
|
||||
L"1.2M",
|
||||
L"1.44M",
|
||||
L"2.88M",
|
||||
L"HardDisk"
|
||||
};
|
||||
|
||||
}}
|
||||
61
7zip/Archive/Iso/IsoHeader.h
Executable file
61
7zip/Archive/Iso/IsoHeader.h
Executable file
@@ -0,0 +1,61 @@
|
||||
// Archive/IsoHeader.h
|
||||
|
||||
#ifndef __ARCHIVE_ISO_HEADER_H
|
||||
#define __ARCHIVE_ISO_HEADER_H
|
||||
|
||||
#include "Common/Types.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
namespace NVolDescType
|
||||
{
|
||||
const Byte kBootRecord = 0;
|
||||
const Byte kPrimaryVol = 1;
|
||||
const Byte kSupplementaryVol = 2;
|
||||
const Byte kVolParttition = 3;
|
||||
const Byte kTerminator = 255;
|
||||
}
|
||||
|
||||
const Byte kVersion = 1;
|
||||
|
||||
namespace NFileFlags
|
||||
{
|
||||
const Byte kDirectory = 1 << 1;
|
||||
}
|
||||
|
||||
extern const char *kElToritoSpec;
|
||||
|
||||
const UInt32 kStartPos = 0x8000;
|
||||
|
||||
namespace NBootEntryId
|
||||
{
|
||||
const Byte kValidationEntry = 1;
|
||||
const Byte kInitialEntryNotBootable = 0;
|
||||
const Byte kInitialEntryBootable = 0x88;
|
||||
}
|
||||
|
||||
namespace NBootPlatformId
|
||||
{
|
||||
const Byte kX86 = 0;
|
||||
const Byte kPowerPC = 1;
|
||||
const Byte kMac = 2;
|
||||
}
|
||||
|
||||
const BYTE kBootMediaTypeMask = 0xF;
|
||||
|
||||
namespace NBootMediaType
|
||||
{
|
||||
const Byte kNoEmulation = 0;
|
||||
const Byte k1d2Floppy = 1;
|
||||
const Byte k1d44Floppy = 2;
|
||||
const Byte k2d88Floppy = 3;
|
||||
const Byte kHardDisk = 4;
|
||||
}
|
||||
|
||||
const int kNumBootMediaTypes = 5;
|
||||
extern const wchar_t *kMediaTypes[];
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
435
7zip/Archive/Iso/IsoIn.cpp
Executable file
435
7zip/Archive/Iso/IsoIn.cpp
Executable file
@@ -0,0 +1,435 @@
|
||||
// Archive/IsoIn.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "IsoIn.h"
|
||||
#include "IsoHeader.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
|
||||
{
|
||||
return ReadStream(_stream, data, size, &processedSize);
|
||||
}
|
||||
|
||||
Byte CInArchive::ReadByte()
|
||||
{
|
||||
if (m_BufferPos >= BlockSize)
|
||||
m_BufferPos = 0;
|
||||
if (m_BufferPos == 0)
|
||||
{
|
||||
UInt32 processedSize;
|
||||
if (ReadBytes(m_Buffer, BlockSize, processedSize) != S_OK)
|
||||
throw 1;
|
||||
if (processedSize != BlockSize)
|
||||
throw 1;
|
||||
}
|
||||
Byte b = m_Buffer[m_BufferPos++];
|
||||
_position++;
|
||||
return b;
|
||||
}
|
||||
|
||||
void CInArchive::ReadBytes(Byte *data, UInt32 size)
|
||||
{
|
||||
for (UInt32 i = 0; i < size; i++)
|
||||
data[i] = ReadByte();
|
||||
}
|
||||
|
||||
void CInArchive::Skeep(size_t size)
|
||||
{
|
||||
while (size-- != 0)
|
||||
ReadByte();
|
||||
}
|
||||
|
||||
void CInArchive::SkeepZeros(size_t size)
|
||||
{
|
||||
while (size-- != 0)
|
||||
{
|
||||
Byte b = ReadByte();
|
||||
if (b != 0)
|
||||
throw 1;
|
||||
}
|
||||
}
|
||||
|
||||
UInt16 CInArchive::ReadUInt16Spec()
|
||||
{
|
||||
UInt16 value = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
value |= ((UInt16)(ReadByte()) << (8 * i));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
UInt16 CInArchive::ReadUInt16()
|
||||
{
|
||||
Byte b[4];
|
||||
ReadBytes(b, 4);
|
||||
UInt32 value = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (b[i] != b[3 - i])
|
||||
throw 1;
|
||||
value |= ((UInt16)(b[i]) << (8 * i));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
UInt32 CInArchive::ReadUInt32Le()
|
||||
{
|
||||
UInt32 value = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
value |= ((UInt32)(ReadByte()) << (8 * i));
|
||||
return value;
|
||||
}
|
||||
|
||||
UInt32 CInArchive::ReadUInt32Be()
|
||||
{
|
||||
UInt32 value = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
value <<= 8;
|
||||
value |= ReadByte();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
UInt32 CInArchive::ReadUInt32()
|
||||
{
|
||||
Byte b[8];
|
||||
ReadBytes(b, 8);
|
||||
UInt32 value = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (b[i] != b[7 - i])
|
||||
throw 1;
|
||||
value |= ((UInt32)(b[i]) << (8 * i));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
UInt32 CInArchive::ReadDigits(int numDigits)
|
||||
{
|
||||
UInt32 res = 0;
|
||||
for (int i = 0; i < numDigits; i++)
|
||||
{
|
||||
Byte b = ReadByte();
|
||||
if (b < '0' || b > '9')
|
||||
{
|
||||
if (b == 0) // it's bug in some CD's
|
||||
b = '0';
|
||||
else
|
||||
throw 1;
|
||||
}
|
||||
UInt32 d = (UInt32)(b - '0');
|
||||
res *= 10;
|
||||
res += d;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void CInArchive::ReadDateTime(CDateTime &d)
|
||||
{
|
||||
d.Year = ReadDigits(4);
|
||||
d.Month = ReadDigits(2);
|
||||
d.Day = ReadDigits(2);
|
||||
d.Hour = ReadDigits(2);
|
||||
d.Minute = ReadDigits(2);
|
||||
d.Second = ReadDigits(2);
|
||||
d.Hundredths = ReadDigits(2);
|
||||
d.GmtOffset = (signed char)ReadByte();
|
||||
}
|
||||
|
||||
void CInArchive::ReadBootRecordDescriptor(CBootRecordDescriptor &d)
|
||||
{
|
||||
ReadBytes(d.BootSystemId, sizeof(d.BootSystemId));
|
||||
ReadBytes(d.BootId, sizeof(d.BootId));
|
||||
ReadBytes(d.BootSystemUse, sizeof(d.BootSystemUse));
|
||||
}
|
||||
|
||||
void CInArchive::ReadRecordingDateTime(CRecordingDateTime &t)
|
||||
{
|
||||
t.Year = ReadByte();
|
||||
t.Month = ReadByte();
|
||||
t.Day = ReadByte();
|
||||
t.Hour = ReadByte();
|
||||
t.Minute = ReadByte();
|
||||
t.Second = ReadByte();
|
||||
t.GmtOffset = (signed char)ReadByte();
|
||||
}
|
||||
|
||||
void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len)
|
||||
{
|
||||
r.ExtendedAttributeRecordLen = ReadByte();
|
||||
if (r.ExtendedAttributeRecordLen != 0)
|
||||
throw 1;
|
||||
r.ExtentLocation = ReadUInt32();
|
||||
r.DataLength = ReadUInt32();
|
||||
ReadRecordingDateTime(r.DateTime);
|
||||
r.FileFlags = ReadByte();
|
||||
r.FileUnitSize = ReadByte();
|
||||
r.InterleaveGapSize = ReadByte();
|
||||
r.VolSequenceNumber = ReadUInt16();
|
||||
Byte idLen = ReadByte();
|
||||
r.FileId.SetCapacity(idLen);
|
||||
ReadBytes((Byte *)r.FileId, idLen);
|
||||
int padSize = 1 - (idLen & 1);
|
||||
|
||||
// SkeepZeros(1 - (idLen & 1));
|
||||
Skeep(1 - (idLen & 1)); // it's bug in some cd's. Must be zeros
|
||||
|
||||
int curPos = 33 + idLen + padSize;
|
||||
if (curPos > len)
|
||||
throw 1;
|
||||
int rem = len - curPos;
|
||||
r.SystemUse.SetCapacity(rem);
|
||||
ReadBytes((Byte *)r.SystemUse, rem);
|
||||
}
|
||||
|
||||
void CInArchive::ReadDirRecord(CDirRecord &r)
|
||||
{
|
||||
Byte len = ReadByte();
|
||||
ReadDirRecord2(r, len);
|
||||
}
|
||||
|
||||
void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
|
||||
{
|
||||
d.VolFlags = ReadByte();
|
||||
ReadBytes(d.SystemId, sizeof(d.SystemId));
|
||||
ReadBytes(d.VolumeId, sizeof(d.VolumeId));
|
||||
SkeepZeros(8);
|
||||
d.VolumeSpaceSize = ReadUInt32();
|
||||
ReadBytes(d.EscapeSequence, sizeof(d.EscapeSequence));
|
||||
d.VolumeSetSize = ReadUInt16();
|
||||
d.VolumeSequenceNumber = ReadUInt16();
|
||||
d.LogicalBlockSize = ReadUInt16();
|
||||
d.PathTableSize = ReadUInt32();
|
||||
d.LPathTableLocation = ReadUInt32Le();
|
||||
d.LOptionalPathTableLocation = ReadUInt32Le();
|
||||
d.MPathTableLocation = ReadUInt32Be();
|
||||
d.MOptionalPathTableLocation = ReadUInt32Be();
|
||||
ReadDirRecord(d.RootDirRecord);
|
||||
ReadBytes(d.VolumeSetId, sizeof(d.VolumeSetId));
|
||||
ReadBytes(d.PublisherId, sizeof(d.PublisherId));
|
||||
ReadBytes(d.DataPreparerId, sizeof(d.DataPreparerId));
|
||||
ReadBytes(d.ApplicationId, sizeof(d.ApplicationId));
|
||||
ReadBytes(d.CopyrightFileId, sizeof(d.CopyrightFileId));
|
||||
ReadBytes(d.AbstractFileId, sizeof(d.AbstractFileId));
|
||||
ReadBytes(d.BibFileId, sizeof(d.BibFileId));
|
||||
ReadDateTime(d.CreationTime);
|
||||
ReadDateTime(d.ModificationTime);
|
||||
ReadDateTime(d.ExpirationTime);
|
||||
ReadDateTime(d.EffectiveTime);
|
||||
d.FileStructureVersion = ReadByte(); // = 1
|
||||
SkeepZeros(1);
|
||||
ReadBytes(d.ApplicationUse, sizeof(d.ApplicationUse));
|
||||
SkeepZeros(653);
|
||||
}
|
||||
|
||||
static inline bool CheckDescriptorSignature(const Byte *sig)
|
||||
{
|
||||
return sig[0] == 'C' &&
|
||||
sig[1] == 'D' &&
|
||||
sig[2] == '0' &&
|
||||
sig[3] == '0' &&
|
||||
sig[4] == '1';
|
||||
}
|
||||
|
||||
void CInArchive::SeekToBlock(UInt32 blockIndex)
|
||||
{
|
||||
if (_stream->Seek((UInt64)blockIndex * VolDescs[MainVolDescIndex].LogicalBlockSize, STREAM_SEEK_SET, &_position) != S_OK)
|
||||
throw 1;
|
||||
m_BufferPos = 0;
|
||||
}
|
||||
|
||||
void CInArchive::ReadDir(CDir &d, int level)
|
||||
{
|
||||
if (!d.IsDir())
|
||||
return;
|
||||
SeekToBlock(d.ExtentLocation);
|
||||
UInt64 startPos = _position;
|
||||
|
||||
bool firstItem = true;
|
||||
while(true)
|
||||
{
|
||||
UInt64 offset = _position - startPos;
|
||||
if (offset >= d.DataLength)
|
||||
break;
|
||||
Byte len = ReadByte();
|
||||
if (len == 0)
|
||||
continue;
|
||||
CDir subItem;
|
||||
ReadDirRecord2(subItem, len);
|
||||
if (firstItem && level == 0)
|
||||
IsSusp = subItem.CheckSusp(SuspSkipSize);
|
||||
|
||||
if (!subItem.IsSystemItem())
|
||||
d._subItems.Add(subItem);
|
||||
|
||||
firstItem = false;
|
||||
}
|
||||
for (int i = 0; i < d._subItems.Size(); i++)
|
||||
ReadDir(d._subItems[i], level + 1);
|
||||
}
|
||||
|
||||
void CInArchive::CreateRefs(CDir &d)
|
||||
{
|
||||
if (!d.IsDir())
|
||||
return;
|
||||
for (int i = 0; i < d._subItems.Size(); i++)
|
||||
{
|
||||
CRef ref;
|
||||
CDir &subItem = d._subItems[i];
|
||||
subItem.Parent = &d;
|
||||
ref.Dir = &d;
|
||||
ref.Index = i;
|
||||
Refs.Add(ref);
|
||||
CreateRefs(subItem);
|
||||
}
|
||||
}
|
||||
|
||||
void CInArchive::ReadBootInfo()
|
||||
{
|
||||
if (!_bootIsDefined)
|
||||
return;
|
||||
if (memcmp(_bootDesc.BootSystemId, kElToritoSpec, sizeof(_bootDesc.BootSystemId)) != 0)
|
||||
return;
|
||||
|
||||
const Byte *p = (const Byte *)_bootDesc.BootSystemUse;
|
||||
UInt32 blockIndex = p[0] | ((UInt32)p[1] << 8) | ((UInt32)p[2] << 16) | ((UInt32)p[3] << 24);
|
||||
SeekToBlock(blockIndex);
|
||||
Byte b = ReadByte();
|
||||
if (b != NBootEntryId::kValidationEntry)
|
||||
return;
|
||||
{
|
||||
CBootValidationEntry e;
|
||||
e.PlatformId = ReadByte();
|
||||
if (ReadUInt16Spec() != 0)
|
||||
throw 1;
|
||||
ReadBytes(e.Id, sizeof(e.Id));
|
||||
UInt16 checkSum = ReadUInt16Spec();
|
||||
if (ReadByte() != 0x55)
|
||||
throw 1;
|
||||
if (ReadByte() != 0xAA)
|
||||
throw 1;
|
||||
}
|
||||
b = ReadByte();
|
||||
if (b == NBootEntryId::kInitialEntryBootable || b == NBootEntryId::kInitialEntryNotBootable)
|
||||
{
|
||||
CBootInitialEntry e;
|
||||
e.Bootable = (b == NBootEntryId::kInitialEntryBootable);
|
||||
e.BootMediaType = ReadByte();
|
||||
e.LoadSegment = ReadUInt16Spec();
|
||||
e.SystemType = ReadByte();
|
||||
if (ReadByte() != 0)
|
||||
throw 1;
|
||||
e.SectorCount = ReadUInt16Spec();
|
||||
e.LoadRBA = ReadUInt32Le();
|
||||
if (ReadByte() != 0)
|
||||
throw 1;
|
||||
BootEntries.Add(e);
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::Open2()
|
||||
{
|
||||
Clear();
|
||||
RINOK(_stream->Seek(kStartPos, STREAM_SEEK_CUR, &_position));
|
||||
|
||||
bool primVolDescDefined = false;
|
||||
m_BufferPos = 0;
|
||||
BlockSize = kBlockSize;
|
||||
VolDescs.Add(CVolumeDescriptor());
|
||||
while(true)
|
||||
{
|
||||
Byte sig[6];
|
||||
ReadBytes(sig, 6);
|
||||
if (!CheckDescriptorSignature(sig + 1))
|
||||
return S_FALSE;
|
||||
if (ReadByte() != kVersion)
|
||||
throw 1;
|
||||
if (sig[0] == NVolDescType::kTerminator)
|
||||
break;
|
||||
switch(sig[0])
|
||||
{
|
||||
case NVolDescType::kBootRecord:
|
||||
{
|
||||
_bootIsDefined = true;
|
||||
ReadBootRecordDescriptor(_bootDesc);
|
||||
break;
|
||||
}
|
||||
case NVolDescType::kPrimaryVol:
|
||||
{
|
||||
if (primVolDescDefined)
|
||||
return S_FALSE;
|
||||
primVolDescDefined = true;
|
||||
CVolumeDescriptor &volDesc = VolDescs[0];
|
||||
ReadVolumeDescriptor(volDesc);
|
||||
// some burners write "Joliet" Escape Sequence to primary volume
|
||||
memset(volDesc.EscapeSequence, 0, sizeof(volDesc.EscapeSequence));
|
||||
break;
|
||||
}
|
||||
case NVolDescType::kSupplementaryVol:
|
||||
{
|
||||
CVolumeDescriptor sd;
|
||||
ReadVolumeDescriptor(sd);
|
||||
VolDescs.Add(sd);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
MainVolDescIndex = 0;
|
||||
if (!primVolDescDefined)
|
||||
return S_FALSE;
|
||||
for (int i = VolDescs.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
if (VolDescs[i].IsJoliet())
|
||||
{
|
||||
MainVolDescIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// MainVolDescIndex = 0; // to read primary volume
|
||||
if (VolDescs[MainVolDescIndex].LogicalBlockSize != kBlockSize)
|
||||
return S_FALSE;
|
||||
(CDirRecord &)_rootDir = VolDescs[MainVolDescIndex].RootDirRecord;
|
||||
ReadDir(_rootDir, 0);
|
||||
CreateRefs(_rootDir);
|
||||
ReadBootInfo();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::Open(IInStream *inStream)
|
||||
{
|
||||
_stream = inStream;
|
||||
UInt64 pos;
|
||||
RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &pos));
|
||||
RINOK(_stream->Seek(0, STREAM_SEEK_END, &_archiveSize));
|
||||
RINOK(_stream->Seek(pos, STREAM_SEEK_SET, &_position));
|
||||
HRESULT res = S_FALSE;
|
||||
try { res = Open2(); }
|
||||
catch(...) { Clear(); res = S_FALSE; }
|
||||
_stream.Release();
|
||||
return res;
|
||||
}
|
||||
|
||||
void CInArchive::Clear()
|
||||
{
|
||||
Refs.Clear();
|
||||
_rootDir.Clear();
|
||||
VolDescs.Clear();
|
||||
_bootIsDefined = false;
|
||||
BootEntries.Clear();
|
||||
SuspSkipSize = 0;
|
||||
IsSusp = false;
|
||||
}
|
||||
|
||||
}}
|
||||
301
7zip/Archive/Iso/IsoIn.h
Executable file
301
7zip/Archive/Iso/IsoIn.h
Executable file
@@ -0,0 +1,301 @@
|
||||
// Archive/IsoIn.h
|
||||
|
||||
#ifndef __ARCHIVE_ISO_IN_H
|
||||
#define __ARCHIVE_ISO_IN_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "Common/IntToString.h"
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
#include "IsoItem.h"
|
||||
#include "IsoHeader.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
struct CDir: public CDirRecord
|
||||
{
|
||||
CDir *Parent;
|
||||
CObjectVector<CDir> _subItems;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
Parent = 0;
|
||||
_subItems.Clear();
|
||||
}
|
||||
|
||||
int GetLength(bool checkSusp, int skipSize) const
|
||||
{
|
||||
int len = GetLengthCur(checkSusp, skipSize);
|
||||
if (Parent != 0)
|
||||
if (Parent->Parent != 0)
|
||||
len += 1 + Parent->GetLength(checkSusp, skipSize);
|
||||
return len;
|
||||
}
|
||||
|
||||
int GetLengthU() const
|
||||
{
|
||||
int len = FileId.GetCapacity() / 2;
|
||||
if (Parent != 0)
|
||||
if (Parent->Parent != 0)
|
||||
len += 1 + Parent->GetLengthU();
|
||||
return len;
|
||||
}
|
||||
|
||||
AString GetPath(bool checkSusp, int skipSize) const
|
||||
{
|
||||
AString s;
|
||||
int len = GetLength(checkSusp, skipSize);
|
||||
char *p = s.GetBuffer(len + 1);
|
||||
p += len;
|
||||
*p = 0;
|
||||
const CDir *cur = this;
|
||||
while(true)
|
||||
{
|
||||
int curLen = cur->GetLengthCur(checkSusp, skipSize);
|
||||
p -= curLen;
|
||||
memmove(p, (const char *)(const Byte *)cur->GetNameCur(checkSusp, skipSize), curLen);
|
||||
cur = cur->Parent;
|
||||
if (cur == 0)
|
||||
break;
|
||||
if (cur->Parent == 0)
|
||||
break;
|
||||
p--;
|
||||
*p = CHAR_PATH_SEPARATOR;
|
||||
}
|
||||
s.ReleaseBuffer();
|
||||
return s;
|
||||
}
|
||||
|
||||
UString GetPathU() const
|
||||
{
|
||||
UString s;
|
||||
int len = GetLengthU();
|
||||
wchar_t *p = s.GetBuffer(len + 1);
|
||||
p += len;
|
||||
*p = 0;
|
||||
const CDir *cur = this;
|
||||
while(true)
|
||||
{
|
||||
int curLen = cur->FileId.GetCapacity() / 2;
|
||||
p -= curLen;
|
||||
for (int i = 0; i < curLen; i++)
|
||||
{
|
||||
Byte b0 = ((const Byte *)cur->FileId)[i * 2];
|
||||
Byte b1 = ((const Byte *)cur->FileId)[i * 2 + 1];
|
||||
p[i] = ((wchar_t)b0 << 8) | (wchar_t)b1;
|
||||
}
|
||||
cur = cur->Parent;
|
||||
if (cur == 0)
|
||||
break;
|
||||
if (cur->Parent == 0)
|
||||
break;
|
||||
p--;
|
||||
*p = WCHAR_PATH_SEPARATOR;
|
||||
}
|
||||
s.ReleaseBuffer();
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
struct CDateTime
|
||||
{
|
||||
UInt16 Year;
|
||||
Byte Month;
|
||||
Byte Day;
|
||||
Byte Hour;
|
||||
Byte Minute;
|
||||
Byte Second;
|
||||
Byte Hundredths;
|
||||
signed char GmtOffset; // min intervals from -48 (West) to +52 (East) recorded.
|
||||
bool NotSpecified() const { return Year == 0 && Month == 0 && Day == 0 &&
|
||||
Hour == 0 && Minute == 0 && Second == 0 && GmtOffset == 0; }
|
||||
};
|
||||
|
||||
struct CBootRecordDescriptor
|
||||
{
|
||||
Byte BootSystemId[32]; // a-characters
|
||||
Byte BootId[32]; // a-characters
|
||||
Byte BootSystemUse[1977];
|
||||
};
|
||||
|
||||
struct CBootValidationEntry
|
||||
{
|
||||
Byte PlatformId;
|
||||
Byte Id[24]; // to identify the manufacturer/developer of the CD-ROM.
|
||||
};
|
||||
|
||||
struct CBootInitialEntry
|
||||
{
|
||||
bool Bootable;
|
||||
Byte BootMediaType;
|
||||
UInt16 LoadSegment;
|
||||
/* This is the load segment for the initial boot image. If this
|
||||
value is 0 the system will use the traditional segment of 7C0. If this value
|
||||
is non-zero the system will use the specified segment. This applies to x86
|
||||
architectures only. For "flat" model architectures (such as Motorola) this
|
||||
is the address divided by 10. */
|
||||
Byte SystemType; // This must be a copy of byte 5 (System Type) from the
|
||||
// Partition Table found in the boot image.
|
||||
UInt16 SectorCount; // This is the number of virtual/emulated sectors the system
|
||||
// will store at Load Segment during the initial boot procedure.
|
||||
UInt32 LoadRBA; // This is the start address of the virtual disk. CD<43>s use
|
||||
// Relative/Logical block addressing.
|
||||
|
||||
UInt64 GetSize() const
|
||||
{
|
||||
// if (BootMediaType == NBootMediaType::k1d44Floppy) (1440 << 10);
|
||||
return SectorCount * 512;
|
||||
}
|
||||
|
||||
UString GetName() const
|
||||
{
|
||||
UString s;
|
||||
if (Bootable)
|
||||
s += L"Bootable";
|
||||
else
|
||||
s += L"NotBootable";
|
||||
s += L"_";
|
||||
if (BootMediaType >= kNumBootMediaTypes)
|
||||
{
|
||||
wchar_t name[32];
|
||||
ConvertUInt64ToString(BootMediaType, name);
|
||||
s += name;
|
||||
}
|
||||
else
|
||||
s += kMediaTypes[BootMediaType];
|
||||
s += L".img";
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
struct CVolumeDescriptor
|
||||
{
|
||||
Byte VolFlags;
|
||||
Byte SystemId[32]; // a-characters. An identification of a system
|
||||
// which can recognize and act upon the content of the Logical
|
||||
// Sectors with logical Sector Numbers 0 to 15 of the volume.
|
||||
Byte VolumeId[32]; // d-characters. An identification of the volume.
|
||||
UInt32 VolumeSpaceSize; // the number of Logical Blocks in which the Volume Space of the volume is recorded
|
||||
Byte EscapeSequence[32];
|
||||
UInt16 VolumeSetSize;
|
||||
UInt16 VolumeSequenceNumber; // the ordinal number of the volume in the Volume Set of which the volume is a member.
|
||||
UInt16 LogicalBlockSize;
|
||||
UInt32 PathTableSize;
|
||||
UInt32 LPathTableLocation;
|
||||
UInt32 LOptionalPathTableLocation;
|
||||
UInt32 MPathTableLocation;
|
||||
UInt32 MOptionalPathTableLocation;
|
||||
CDirRecord RootDirRecord;
|
||||
Byte VolumeSetId[128];
|
||||
Byte PublisherId[128];
|
||||
Byte DataPreparerId[128];
|
||||
Byte ApplicationId[128];
|
||||
Byte CopyrightFileId[37];
|
||||
Byte AbstractFileId[37];
|
||||
Byte BibFileId[37];
|
||||
CDateTime CreationTime;
|
||||
CDateTime ModificationTime;
|
||||
CDateTime ExpirationTime;
|
||||
CDateTime EffectiveTime;
|
||||
Byte FileStructureVersion; // = 1;
|
||||
Byte ApplicationUse[512];
|
||||
|
||||
bool IsJoliet() const
|
||||
{
|
||||
if ((VolFlags & 1) != 0)
|
||||
return false;
|
||||
Byte b = EscapeSequence[2];
|
||||
return (EscapeSequence[0] == 0x25 && EscapeSequence[1] == 0x2F &&
|
||||
(b == 0x40 || b == 0x43 || b == 0x45));
|
||||
}
|
||||
};
|
||||
|
||||
struct CRef
|
||||
{
|
||||
CDir *Dir;
|
||||
UInt32 Index;
|
||||
};
|
||||
|
||||
const UInt32 kBlockSize = 1 << 11;
|
||||
|
||||
class CInArchive
|
||||
{
|
||||
CMyComPtr<IInStream> _stream;
|
||||
UInt64 _position;
|
||||
|
||||
Byte m_Buffer[kBlockSize];
|
||||
UInt32 m_BufferPos;
|
||||
|
||||
CDir _rootDir;
|
||||
bool _bootIsDefined;
|
||||
CBootRecordDescriptor _bootDesc;
|
||||
|
||||
HRESULT ReadBytes(void *data, UInt32 size, UInt32 &processedSize);
|
||||
void Skeep(size_t size);
|
||||
void SkeepZeros(size_t size);
|
||||
Byte ReadByte();
|
||||
void ReadBytes(Byte *data, UInt32 size);
|
||||
UInt16 ReadUInt16Spec();
|
||||
UInt16 ReadUInt16();
|
||||
UInt32 ReadUInt32Le();
|
||||
UInt32 ReadUInt32Be();
|
||||
UInt32 ReadUInt32();
|
||||
UInt64 ReadUInt64();
|
||||
UInt32 ReadDigits(int numDigits);
|
||||
void ReadDateTime(CDateTime &d);
|
||||
void ReadRecordingDateTime(CRecordingDateTime &t);
|
||||
void ReadDirRecord2(CDirRecord &r, Byte len);
|
||||
void ReadDirRecord(CDirRecord &r);
|
||||
|
||||
void ReadBootRecordDescriptor(CBootRecordDescriptor &d);
|
||||
void ReadVolumeDescriptor(CVolumeDescriptor &d);
|
||||
|
||||
void SeekToBlock(UInt32 blockIndex);
|
||||
void ReadDir(CDir &d, int level);
|
||||
void CreateRefs(CDir &d);
|
||||
|
||||
void ReadBootInfo();
|
||||
HRESULT Open2();
|
||||
public:
|
||||
HRESULT Open(IInStream *inStream);
|
||||
void Clear();
|
||||
|
||||
UInt64 _archiveSize;
|
||||
|
||||
CRecordVector<CRef> Refs;
|
||||
CObjectVector<CVolumeDescriptor> VolDescs;
|
||||
int MainVolDescIndex;
|
||||
UInt32 BlockSize;
|
||||
CObjectVector<CBootInitialEntry> BootEntries;
|
||||
|
||||
|
||||
bool IsJoliet() const { return VolDescs[MainVolDescIndex].IsJoliet(); }
|
||||
|
||||
UInt64 GetBootItemSize(int index) const
|
||||
{
|
||||
const CBootInitialEntry &be = BootEntries[index];
|
||||
UInt64 size = be.GetSize();
|
||||
if (be.BootMediaType == NBootMediaType::k1d2Floppy)
|
||||
size = (1200 << 10);
|
||||
else if (be.BootMediaType == NBootMediaType::k1d44Floppy)
|
||||
size = (1440 << 10);
|
||||
else if (be.BootMediaType == NBootMediaType::k2d88Floppy)
|
||||
size = (2880 << 10);
|
||||
UInt64 startPos = be.LoadRBA * BlockSize;
|
||||
if (startPos < _archiveSize)
|
||||
{
|
||||
if (_archiveSize - startPos < size)
|
||||
size = _archiveSize - startPos;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
bool IsSusp;
|
||||
int SuspSkipSize;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
145
7zip/Archive/Iso/IsoItem.h
Executable file
145
7zip/Archive/Iso/IsoItem.h
Executable file
@@ -0,0 +1,145 @@
|
||||
// Archive/IsoItem.h
|
||||
|
||||
#ifndef __ARCHIVE_ISO_ITEM_H
|
||||
#define __ARCHIVE_ISO_ITEM_H
|
||||
|
||||
#include "Common/Types.h"
|
||||
#include "Common/String.h"
|
||||
#include "Common/Buffer.h"
|
||||
|
||||
#include "IsoHeader.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NIso {
|
||||
|
||||
struct CRecordingDateTime
|
||||
{
|
||||
Byte Year;
|
||||
Byte Month;
|
||||
Byte Day;
|
||||
Byte Hour;
|
||||
Byte Minute;
|
||||
Byte Second;
|
||||
signed char GmtOffset; // min intervals from -48 (West) to +52 (East) recorded.
|
||||
|
||||
bool GetFileTime(FILETIME &ft) const
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
st.wYear = Year + 1900;
|
||||
st.wMonth = Month;
|
||||
st.wDayOfWeek = 0; // check it
|
||||
st.wDay = Day;
|
||||
st.wHour = Hour;
|
||||
st.wMinute = Minute;
|
||||
st.wSecond = Second;
|
||||
st.wMilliseconds = 0;
|
||||
if (!SystemTimeToFileTime(&st, &ft))
|
||||
return false;
|
||||
UInt64 value = (((UInt64)ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||
value += (UInt64)((Int64)(int)GmtOffset * 15 * 60);
|
||||
ft.dwLowDateTime = (DWORD)value;
|
||||
ft.dwHighDateTime = DWORD(value >> 32);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct CDirRecord
|
||||
{
|
||||
Byte ExtendedAttributeRecordLen;
|
||||
UInt32 ExtentLocation;
|
||||
UInt32 DataLength;
|
||||
CRecordingDateTime DateTime;
|
||||
Byte FileFlags;
|
||||
Byte FileUnitSize;
|
||||
Byte InterleaveGapSize;
|
||||
UInt16 VolSequenceNumber;
|
||||
CByteBuffer FileId;
|
||||
CByteBuffer SystemUse;
|
||||
|
||||
bool IsDir() const { return (FileFlags & NFileFlags::kDirectory) != 0; }
|
||||
bool IsSystemItem() const
|
||||
{
|
||||
if (FileId.GetCapacity() != 1)
|
||||
return false;
|
||||
Byte b = *(const Byte *)FileId;
|
||||
return (b == 0 || b == 1);
|
||||
}
|
||||
|
||||
const Byte* FindSuspName(int skipSize, int &lenRes) const
|
||||
{
|
||||
lenRes = 0;
|
||||
const Byte *p = (const Byte *)SystemUse + skipSize;
|
||||
int length = SystemUse.GetCapacity() - skipSize;
|
||||
while (length >= 5)
|
||||
{
|
||||
int len = p[2];
|
||||
if (p[0] == 'N' && p[1] == 'M' && p[3] == 1)
|
||||
{
|
||||
lenRes = len - 5;
|
||||
return p + 5;
|
||||
}
|
||||
p += len;
|
||||
length -= len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetLengthCur(bool checkSusp, int skipSize) const
|
||||
{
|
||||
if (checkSusp)
|
||||
{
|
||||
int len;
|
||||
const Byte *res = FindSuspName(skipSize, len);
|
||||
if (res != 0)
|
||||
return len;
|
||||
}
|
||||
return FileId.GetCapacity();
|
||||
}
|
||||
|
||||
const Byte* GetNameCur(bool checkSusp, int skipSize) const
|
||||
{
|
||||
if (checkSusp)
|
||||
{
|
||||
int len;
|
||||
const Byte *res = FindSuspName(skipSize, len);
|
||||
if (res != 0)
|
||||
return res;
|
||||
}
|
||||
return (const Byte *)FileId;
|
||||
}
|
||||
|
||||
|
||||
bool CheckSusp(const Byte *p, int &startPos) const
|
||||
{
|
||||
if (p[0] == 'S' &&
|
||||
p[1] == 'P' &&
|
||||
p[2] == 0x7 &&
|
||||
p[3] == 0x1 &&
|
||||
p[4] == 0xBE &&
|
||||
p[5] == 0xEF)
|
||||
{
|
||||
startPos = p[6];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckSusp(int &startPos) const
|
||||
{
|
||||
const Byte *p = (const Byte *)SystemUse;
|
||||
int length = SystemUse.GetCapacity();
|
||||
const int kMinLen = 7;
|
||||
if (length < kMinLen)
|
||||
return false;
|
||||
if (CheckSusp(p, startPos))
|
||||
return true;
|
||||
const int kOffset2 = 14;
|
||||
if (length < kOffset2 + kMinLen)
|
||||
return false;
|
||||
return CheckSusp(p + kOffset2, startPos);
|
||||
}
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
3
7zip/Archive/Iso/StdAfx.cpp
Executable file
3
7zip/Archive/Iso/StdAfx.cpp
Executable file
@@ -0,0 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
9
7zip/Archive/Iso/StdAfx.h
Executable file
9
7zip/Archive/Iso/StdAfx.h
Executable file
@@ -0,0 +1,9 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
#include "../../../Common/NewHandler.h"
|
||||
|
||||
#endif
|
||||
55
7zip/Archive/Iso/makefile
Executable file
55
7zip/Archive/Iso/makefile
Executable file
@@ -0,0 +1,55 @@
|
||||
PROG = iso.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
TAR_OBJS = \
|
||||
$O\DllExports.obj \
|
||||
$O\IsoHandler.obj \
|
||||
$O\IsoHeader.obj \
|
||||
$O\IsoIn.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\Vector.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\PropVariant.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\LimitedStreams.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\ItemNameUtils.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(TAR_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(AR_COMMON_OBJS) \
|
||||
$(COMPRESS_TAR_OBJS) \
|
||||
$O\CopyCoder.obj \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(TAR_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(AR_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
5
7zip/Archive/Iso/resource.rc
Executable file
5
7zip/Archive/Iso/resource.rc
Executable file
@@ -0,0 +1,5 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("Iso Plugin", "iso")
|
||||
|
||||
101 ICON "iso.ico"
|
||||
@@ -140,9 +140,13 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
const UString s = NItemName::GetOSName2(MultiByteToUnicodeString(item.GetName(), CP_OEMCP));
|
||||
UString s = NItemName::WinNameToOSName(MultiByteToUnicodeString(item.GetName(), CP_OEMCP));
|
||||
if (!s.IsEmpty())
|
||||
{
|
||||
if (s[s.Length() - 1] == WCHAR_PATH_SEPARATOR)
|
||||
s.Delete(s.Length() - 1);
|
||||
propVariant = s;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kpidIsFolder:
|
||||
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
if (!dirName.IsEmpty())
|
||||
{
|
||||
char c = dirName[dirName.Length() - 1];
|
||||
if (c != '\\' && c != '/')
|
||||
if (c != '\\')
|
||||
dirName += '\\';
|
||||
}
|
||||
return dirName + GetFileName();
|
||||
|
||||
110
7zip/Archive/Nsis/DllExports.cpp
Executable file
110
7zip/Archive/Nsis/DllExports.cpp
Executable file
@@ -0,0 +1,110 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "../../ICoder.h"
|
||||
#include "NsisHandler.h"
|
||||
|
||||
// {23170F69-40C1-278A-1000-000110090000}
|
||||
DEFINE_GUID(CLSID_CNsisHandler,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x09, 0x00, 0x00);
|
||||
|
||||
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
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(
|
||||
const GUID *classID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
if (*classID != CLSID_CNsisHandler)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
int needIn = *interfaceID == IID_IInArchive;
|
||||
// int needOut = *interfaceID == IID_IOutArchive;
|
||||
if (needIn /*|| needOut */)
|
||||
{
|
||||
NArchive::NNsis::CHandler *temp = new NArchive::NNsis::CHandler;
|
||||
if (needIn)
|
||||
{
|
||||
CMyComPtr<IInArchive> inArchive = (IInArchive *)temp;
|
||||
*outObject = inArchive.Detach();
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
CMyComPtr<IOutArchive> outArchive = (IOutArchive *)temp;
|
||||
*outObject = outArchive.Detach();
|
||||
}
|
||||
*/
|
||||
}
|
||||
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"Nsis";
|
||||
break;
|
||||
case NArchive::kClassID:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)&CLSID_CNsisHandler, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kExtension:
|
||||
propVariant = L"exe";
|
||||
break;
|
||||
case NArchive::kUpdate:
|
||||
propVariant = false;
|
||||
break;
|
||||
case NArchive::kStartSignature:
|
||||
{
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen((const char *)NArchive::NNsis::kSignature,
|
||||
NArchive::NNsis::kSignatureSize)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
case NArchive::kAssociate:
|
||||
{
|
||||
propVariant = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
}
|
||||
337
7zip/Archive/Nsis/Nsis.dsp
Executable file
337
7zip/Archive/Nsis/Nsis.dsp
Executable file
@@ -0,0 +1,337 @@
|
||||
# Microsoft Developer Studio Project File - Name="Nsis" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Nsis - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Nsis.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Nsis.mak" CFG="Nsis - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Nsis - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Nsis - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Nsis - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# 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 "TAR_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /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"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Formats\nsis.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Nsis - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# 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 "TAR_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /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"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Formats\nsis.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Nsis - Win32 Release"
|
||||
# Name "Nsis - Win32 Debug"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Archive.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DllExports.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Nsis.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"StdAfx.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# 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
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\String.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Vector.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileFind.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileFind.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Copy\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Engine"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisDecode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisDecode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\NsisIn.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Archive Common"
|
||||
|
||||
# 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\FilterCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\FilterCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ItemNameUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ItemNameUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\LimitedStreams.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamObjects.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamObjects.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7z"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\7z\7zMethodID.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\7z\7zMethodID.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\7z\7zMethods.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\7z\7zMethods.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
7zip/Archive/Nsis/Nsis.dsw
Executable file
29
7zip/Archive/Nsis/Nsis.dsw
Executable file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Nsis"=.\Nsis.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
150
7zip/Archive/Nsis/NsisDecode.cpp
Executable file
150
7zip/Archive/Nsis/NsisDecode.cpp
Executable file
@@ -0,0 +1,150 @@
|
||||
// NsisDecode.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "NsisDecode.h"
|
||||
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "../7z/7zMethods.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
static const N7z::CMethodID k_Copy = { { 0x0 }, 1 };
|
||||
static const N7z::CMethodID k_Deflate = { { 0x4, 0x9, 0x1 }, 3 };
|
||||
static const N7z::CMethodID k_BZip2 = { { 0x4, 0x9, 0x2 }, 3 };
|
||||
static const N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
|
||||
static const N7z::CMethodID k_BCJ_X86 = { { 0x3, 0x3, 0x1, 0x3 }, 4 };
|
||||
|
||||
CDecoder::CDecoder()
|
||||
{
|
||||
N7z::LoadMethodMap();
|
||||
}
|
||||
|
||||
HRESULT CDecoder::Init(IInStream *inStream, NMethodType::EEnum method, bool thereIsFilterFlag, bool &useFilter)
|
||||
{
|
||||
useFilter = false;
|
||||
CObjectVector< CMyComPtr<ISequentialInStream> > inStreams;
|
||||
|
||||
if (_decoderInStream)
|
||||
if (method != _method)
|
||||
Release();
|
||||
_method = method;
|
||||
if (!_codecInStream)
|
||||
{
|
||||
const NArchive::N7z::CMethodID *methodID = 0;
|
||||
switch (method)
|
||||
{
|
||||
case NMethodType::kCopy:
|
||||
methodID = &k_Copy;
|
||||
break;
|
||||
case NMethodType::kDeflate:
|
||||
methodID = &k_Deflate;
|
||||
break;
|
||||
case NMethodType::kBZip2:
|
||||
methodID = &k_BZip2;
|
||||
break;
|
||||
case NMethodType::kLZMA:
|
||||
methodID = &k_LZMA;
|
||||
break;
|
||||
default:
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
N7z::CMethodInfo methodInfo;
|
||||
if (!N7z::GetMethodInfo(*methodID, methodInfo))
|
||||
return E_NOTIMPL;
|
||||
CMyComPtr<ICompressCoder> coder;
|
||||
RINOK(_libraries.CreateCoder(methodInfo.FilePath, methodInfo.Decoder, &coder));
|
||||
coder.QueryInterface(IID_ISequentialInStream, &_codecInStream);
|
||||
if (!_codecInStream)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if (thereIsFilterFlag)
|
||||
{
|
||||
UInt32 processedSize;
|
||||
BYTE flag;
|
||||
RINOK(inStream->Read(&flag, 1, &processedSize));
|
||||
if (processedSize != 1)
|
||||
return E_FAIL;
|
||||
if (flag > 1)
|
||||
return E_NOTIMPL;
|
||||
useFilter = (flag != 0);
|
||||
}
|
||||
|
||||
if (useFilter)
|
||||
{
|
||||
if (!_filterInStream)
|
||||
{
|
||||
N7z::CMethodInfo methodInfo;
|
||||
if (!N7z::GetMethodInfo(k_BCJ_X86, methodInfo))
|
||||
return E_NOTIMPL;
|
||||
CMyComPtr<ICompressCoder> coder;
|
||||
RINOK(_libraries.CreateCoderSpec(methodInfo.FilePath, methodInfo.Decoder, &coder));
|
||||
coder.QueryInterface(IID_ISequentialInStream, &_filterInStream);
|
||||
if (!_filterInStream)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
CMyComPtr<ICompressSetInStream> setInStream;
|
||||
_filterInStream.QueryInterface(IID_ICompressSetInStream, &setInStream);
|
||||
if (!setInStream)
|
||||
return E_NOTIMPL;
|
||||
RINOK(setInStream->SetInStream(_codecInStream));
|
||||
_decoderInStream = _filterInStream;
|
||||
}
|
||||
else
|
||||
_decoderInStream = _codecInStream;
|
||||
|
||||
if (method == NMethodType::kLZMA)
|
||||
{
|
||||
CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
|
||||
_codecInStream.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
|
||||
if (setDecoderProperties)
|
||||
{
|
||||
static const UInt32 kPropertiesSize = 5;
|
||||
BYTE properties[kPropertiesSize];
|
||||
UInt32 processedSize;
|
||||
RINOK(inStream->Read(properties, kPropertiesSize, &processedSize));
|
||||
if (processedSize != kPropertiesSize)
|
||||
return E_FAIL;
|
||||
RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)properties, kPropertiesSize));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
CMyComPtr<ICompressSetInStream> setInStream;
|
||||
_codecInStream.QueryInterface(IID_ICompressSetInStream, &setInStream);
|
||||
if (!setInStream)
|
||||
return E_NOTIMPL;
|
||||
RINOK(setInStream->SetInStream(inStream));
|
||||
}
|
||||
|
||||
{
|
||||
CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize;
|
||||
_codecInStream.QueryInterface(IID_ICompressSetOutStreamSize, &setOutStreamSize);
|
||||
if (!setOutStreamSize)
|
||||
return E_NOTIMPL;
|
||||
RINOK(setOutStreamSize->SetOutStreamSize(NULL));
|
||||
}
|
||||
|
||||
if (useFilter)
|
||||
{
|
||||
/*
|
||||
CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize;
|
||||
_filterInStream.QueryInterface(IID_ICompressSetOutStreamSize, &setOutStreamSize);
|
||||
if (!setOutStreamSize)
|
||||
return E_NOTIMPL;
|
||||
RINOK(setOutStreamSize->SetOutStreamSize(NULL));
|
||||
*/
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
return ReadStream(_decoderInStream, data, size, processedSize);;
|
||||
}
|
||||
|
||||
}}
|
||||
47
7zip/Archive/Nsis/NsisDecode.h
Executable file
47
7zip/Archive/Nsis/NsisDecode.h
Executable file
@@ -0,0 +1,47 @@
|
||||
// NsisDecode.h
|
||||
|
||||
#ifndef __NSIS_DECODE_H
|
||||
#define __NSIS_DECODE_H
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
#include "../Common/CoderLoader.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
namespace NMethodType
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kCopy,
|
||||
kDeflate,
|
||||
kBZip2,
|
||||
kLZMA
|
||||
};
|
||||
}
|
||||
|
||||
class CDecoder
|
||||
{
|
||||
NMethodType::EEnum _method;
|
||||
CCoderLibraries _libraries;
|
||||
|
||||
CMyComPtr<ISequentialInStream> _filterInStream;
|
||||
CMyComPtr<ISequentialInStream> _codecInStream;
|
||||
CMyComPtr<ISequentialInStream> _decoderInStream;
|
||||
|
||||
public:
|
||||
CDecoder();
|
||||
void Release()
|
||||
{
|
||||
_filterInStream.Release();
|
||||
_codecInStream.Release();
|
||||
_decoderInStream.Release();
|
||||
}
|
||||
HRESULT Init(IInStream *inStream, NMethodType::EEnum method, bool thereIsFilterFlag, bool &useFilter);
|
||||
HRESULT Read(void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
484
7zip/Archive/Nsis/NsisHandler.cpp
Executable file
484
7zip/Archive/Nsis/NsisHandler.cpp
Executable file
@@ -0,0 +1,484 @@
|
||||
// NSisHandler.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "NsisHandler.h"
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/NewHandler.h"
|
||||
#include "Common/ComTry.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
static const wchar_t *kBcjMethod = L"BCJ";
|
||||
static const wchar_t *kUnknownMethod = L"Unknown";
|
||||
|
||||
static const wchar_t *kMethods[] =
|
||||
{
|
||||
L"Copy",
|
||||
L"Deflate",
|
||||
L"BZip2",
|
||||
L"LZMA"
|
||||
};
|
||||
|
||||
static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
|
||||
|
||||
STATPROPSTG kProperties[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidIsFolder, VT_BOOL},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
{ NULL, kpidPackedSize, VT_UI8},
|
||||
{ NULL, kpidLastWriteTime, VT_FILETIME},
|
||||
{ NULL, kpidMethod, VT_BSTR},
|
||||
{ NULL, kpidSolid, VT_BOOL}
|
||||
};
|
||||
|
||||
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
value->vt = VT_EMPTY;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
|
||||
return E_INVALIDARG;
|
||||
const STATPROPSTG &srcItem = kProperties[index];
|
||||
*propID = srcItem.propid;
|
||||
*varType = srcItem.vt;
|
||||
*name = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
|
||||
{
|
||||
*numProperties = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
|
||||
{
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
bool mustBeClosed = true;
|
||||
Close();
|
||||
{
|
||||
if(_archive.Open(stream, maxCheckStartPosition) != S_OK)
|
||||
return S_FALSE;
|
||||
_inStream = stream;
|
||||
}
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
{
|
||||
_archive.Clear();
|
||||
_archive.Release();
|
||||
_inStream.Release();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
{
|
||||
*numItems = _archive.Items.Size()
|
||||
#ifdef NSIS_SCRIPT
|
||||
+ 1
|
||||
#endif
|
||||
;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static UString ConvertUInt32ToString(UInt32 value)
|
||||
{
|
||||
wchar_t buffer[32];
|
||||
ConvertUInt64ToString(value, buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static UString GetStringForSizeValue(UInt32 value)
|
||||
{
|
||||
for (int i = 31; i >= 0; i--)
|
||||
if ((UInt32(1) << i) == value)
|
||||
return ConvertUInt32ToString(i);
|
||||
UString result;
|
||||
if (value % (1 << 20) == 0)
|
||||
{
|
||||
result += ConvertUInt32ToString(value >> 20);
|
||||
result += L"m";
|
||||
}
|
||||
else if (value % (1 << 10) == 0)
|
||||
{
|
||||
result += ConvertUInt32ToString(value >> 10);
|
||||
result += L"k";
|
||||
}
|
||||
else
|
||||
{
|
||||
result += ConvertUInt32ToString(value);
|
||||
result += L"b";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CHandler::GetUncompressedSize(int index, UInt32 &size)
|
||||
{
|
||||
size = 0;
|
||||
const CItem &item = _archive.Items[index];
|
||||
if (item.SizeIsDefined)
|
||||
size = item.Size;
|
||||
else if (_archive.IsSolid && item.EstimatedSizeIsDefined)
|
||||
size = item.EstimatedSize;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHandler::GetCompressedSize(int index, UInt32 &size)
|
||||
{
|
||||
size = 0;
|
||||
const CItem &item = _archive.Items[index];
|
||||
if (item.CompressedSizeIsDefined)
|
||||
size = item.CompressedSize;
|
||||
else
|
||||
{
|
||||
if (_archive.IsSolid)
|
||||
{
|
||||
if (index == 0)
|
||||
size = _archive.FirstHeader.GetDataSize();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!item.IsCompressed)
|
||||
size = item.Size;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NWindows::NCOM::CPropVariant propVariant;
|
||||
#ifdef NSIS_SCRIPT
|
||||
if (index >= (UInt32)_archive.Items.Size())
|
||||
{
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
propVariant = L"[NSIS].nsi";
|
||||
break;
|
||||
case kpidIsFolder:
|
||||
propVariant = false;
|
||||
break;
|
||||
case kpidSize:
|
||||
case kpidPackedSize:
|
||||
propVariant = (UInt64)_archive.Script.Length();
|
||||
break;
|
||||
case kpidSolid:
|
||||
propVariant = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
const CItem &item = _archive.Items[index];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
const UString s = NItemName::WinNameToOSName(MultiByteToUnicodeString(item.GetReducedName(), CP_ACP));
|
||||
propVariant = (const wchar_t *)s;
|
||||
break;
|
||||
}
|
||||
case kpidIsFolder:
|
||||
propVariant = false;
|
||||
break;
|
||||
case kpidSize:
|
||||
{
|
||||
UInt32 size;
|
||||
if (GetUncompressedSize(index, size))
|
||||
propVariant = (UInt64)size;
|
||||
break;
|
||||
}
|
||||
case kpidPackedSize:
|
||||
{
|
||||
UInt32 size;
|
||||
if (GetCompressedSize(index, size))
|
||||
propVariant = (UInt64)size;
|
||||
break;
|
||||
}
|
||||
case kpidLastWriteTime:
|
||||
{
|
||||
if (item.DateTime.dwHighDateTime > 0x01000000 &&
|
||||
item.DateTime.dwHighDateTime < 0xFF000000)
|
||||
propVariant = item.DateTime;
|
||||
break;
|
||||
}
|
||||
case kpidMethod:
|
||||
{
|
||||
NMethodType::EEnum methodIndex = _archive.Method;
|
||||
UString method;
|
||||
if (_archive.IsSolid && _archive.UseFilter || !_archive.IsSolid && item.UseFilter)
|
||||
{
|
||||
method += kBcjMethod;
|
||||
method += L" ";
|
||||
}
|
||||
method += (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
|
||||
if (methodIndex == NMethodType::kLZMA)
|
||||
{
|
||||
method += L":";
|
||||
method += GetStringForSizeValue(_archive.IsSolid ? _archive.DictionarySize: item.DictionarySize);
|
||||
}
|
||||
propVariant = method;
|
||||
break;
|
||||
}
|
||||
case kpidSolid:
|
||||
propVariant = _archive.IsSolid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
propVariant.Detach(value);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
bool testMode = (_aTestMode != 0);
|
||||
bool allFilesMode = (numItems == UInt32(-1));
|
||||
if (allFilesMode)
|
||||
GetNumberOfItems(&numItems);
|
||||
if(numItems == 0)
|
||||
return S_OK;
|
||||
UInt64 totalSize = 0;
|
||||
|
||||
UInt32 i;
|
||||
for(i = 0; i < numItems; i++)
|
||||
{
|
||||
UInt32 index = (allFilesMode ? i : indices[i]);
|
||||
#ifdef NSIS_SCRIPT
|
||||
if (index >= (UInt32)_archive.Items.Size())
|
||||
totalSize += _archive.Script.Length();
|
||||
else
|
||||
#endif
|
||||
{
|
||||
UInt32 size;
|
||||
if (_archive.IsSolid)
|
||||
{
|
||||
GetUncompressedSize(index, size);
|
||||
UInt64 pos = _archive.GetPosOfSolidItem(index);
|
||||
if (pos > totalSize)
|
||||
totalSize = pos + size;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetCompressedSize(index, size);
|
||||
totalSize += size;
|
||||
}
|
||||
}
|
||||
}
|
||||
extractCallback->SetTotal(totalSize);
|
||||
|
||||
UInt64 currentTotalSize = 0;
|
||||
UInt32 currentItemSize = 0;
|
||||
|
||||
UInt64 streamPos = 0;
|
||||
if (_archive.IsSolid)
|
||||
{
|
||||
RINOK(_inStream->Seek(_archive.StreamOffset, STREAM_SEEK_SET, NULL));
|
||||
bool useFilter;
|
||||
RINOK(_archive.Decoder.Init(_inStream, _archive.Method, _archive.FilterFlag, useFilter));
|
||||
}
|
||||
|
||||
bool dataError = false;
|
||||
for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
|
||||
{
|
||||
currentItemSize = 0;
|
||||
RINOK(extractCallback->SetCompleted(¤tTotalSize));
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
Int32 askMode;
|
||||
askMode = testMode ? NArchive::NExtract::NAskMode::kTest : NArchive::NExtract::NAskMode::kExtract;
|
||||
UInt32 index = allFilesMode ? i : indices[i];
|
||||
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
||||
|
||||
#ifdef NSIS_SCRIPT
|
||||
if (index >= (UInt32)_archive.Items.Size())
|
||||
{
|
||||
currentItemSize = _archive.Script.Length();
|
||||
if(!testMode && (!realOutStream))
|
||||
continue;
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
if (!testMode)
|
||||
RINOK(realOutStream->Write((const char *)_archive.Script, (UInt32)_archive.Script.Length(), NULL));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
const CItem &item = _archive.Items[index];
|
||||
|
||||
if (_archive.IsSolid)
|
||||
GetUncompressedSize(index, currentItemSize);
|
||||
else
|
||||
GetCompressedSize(index, currentItemSize);
|
||||
|
||||
if(!testMode && (!realOutStream))
|
||||
continue;
|
||||
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
|
||||
if (!dataError)
|
||||
{
|
||||
bool needDecompress = false;
|
||||
bool sizeIsKnown = false;
|
||||
UInt32 fullSize = 0;
|
||||
|
||||
const UInt32 kBufferLength = 1 << 11;
|
||||
Byte buffer[kBufferLength];
|
||||
|
||||
if (_archive.IsSolid)
|
||||
{
|
||||
UInt64 pos = _archive.GetPosOfSolidItem(index);
|
||||
while(streamPos < pos)
|
||||
{
|
||||
UInt32 curSize = (UInt32)MyMin(pos - streamPos, (UInt64)kBufferLength);
|
||||
UInt32 processedSize;
|
||||
HRESULT res = _archive.Decoder.Read(buffer, curSize, &processedSize);
|
||||
if (res != S_OK)
|
||||
{
|
||||
if (res != S_FALSE)
|
||||
return res;
|
||||
dataError = true;
|
||||
break;
|
||||
}
|
||||
if (processedSize == 0)
|
||||
{
|
||||
dataError = true;
|
||||
break;
|
||||
}
|
||||
streamPos += processedSize;
|
||||
}
|
||||
if (streamPos == pos)
|
||||
{
|
||||
UInt32 processedSize;
|
||||
RINOK(_archive.Decoder.Read(buffer, 4, &processedSize));
|
||||
if (processedSize != 4)
|
||||
return E_FAIL;
|
||||
streamPos += processedSize;
|
||||
fullSize = GetUInt32FromMemLE(buffer);
|
||||
sizeIsKnown = true;
|
||||
needDecompress = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(_inStream->Seek(_archive.GetPosOfNonSolidItem(index) + 4, STREAM_SEEK_SET, NULL));
|
||||
if (item.IsCompressed)
|
||||
{
|
||||
needDecompress = true;
|
||||
bool useFilter;
|
||||
RINOK(_archive.Decoder.Init(_inStream, _archive.Method, _archive.FilterFlag, useFilter));
|
||||
fullSize = GetUInt32FromMemLE(buffer);
|
||||
}
|
||||
else
|
||||
fullSize = item.Size;
|
||||
}
|
||||
if (!dataError)
|
||||
{
|
||||
if (needDecompress)
|
||||
{
|
||||
UInt64 offset = 0;
|
||||
while(!sizeIsKnown || fullSize > 0)
|
||||
{
|
||||
UInt32 curSize = kBufferLength;
|
||||
if (sizeIsKnown && curSize > fullSize)
|
||||
curSize = fullSize;
|
||||
UInt32 processedSize;
|
||||
HRESULT res = _archive.Decoder.Read(buffer, curSize, &processedSize);
|
||||
if (res != S_OK)
|
||||
{
|
||||
if (res != S_FALSE)
|
||||
return res;
|
||||
dataError = true;
|
||||
break;
|
||||
}
|
||||
if (processedSize == 0)
|
||||
{
|
||||
if (sizeIsKnown)
|
||||
dataError = true;
|
||||
break;
|
||||
}
|
||||
|
||||
fullSize -= processedSize;
|
||||
streamPos += processedSize;
|
||||
offset += processedSize;
|
||||
|
||||
UInt64 completed;
|
||||
if (_archive.IsSolid)
|
||||
completed = streamPos;
|
||||
else
|
||||
completed = currentTotalSize + offset;
|
||||
RINOK(extractCallback->SetCompleted(&completed));
|
||||
if (!testMode)
|
||||
RINOK(realOutStream->Write(buffer, processedSize, NULL));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(fullSize > 0)
|
||||
{
|
||||
UInt32 curSize = MyMin(fullSize, kBufferLength);
|
||||
UInt32 processedSize;
|
||||
RINOK(_inStream->Read(buffer, curSize, &processedSize));
|
||||
if (processedSize == 0)
|
||||
{
|
||||
dataError = true;
|
||||
break;
|
||||
}
|
||||
fullSize -= processedSize;
|
||||
streamPos += processedSize;
|
||||
if (!testMode)
|
||||
RINOK(realOutStream->Write(buffer, processedSize, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!testMode)
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(dataError ?
|
||||
NArchive::NExtract::NOperationResult::kDataError :
|
||||
NArchive::NExtract::NOperationResult::kOK));
|
||||
}
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
}}
|
||||
41
7zip/Archive/Nsis/NsisHandler.h
Executable file
41
7zip/Archive/Nsis/NsisHandler.h
Executable file
@@ -0,0 +1,41 @@
|
||||
// NSisHandler.h
|
||||
|
||||
#ifndef __NSIS_HANDLER_H
|
||||
#define __NSIS_HANDLER_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "../IArchive.h"
|
||||
|
||||
#include "NsisIn.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
class CHandler:
|
||||
public IInArchive,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CMyComPtr<IInStream> _inStream;
|
||||
CInArchive _archive;
|
||||
|
||||
bool GetUncompressedSize(int index, UInt32 &size);
|
||||
bool GetCompressedSize(int index, UInt32 &size);
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback);
|
||||
STDMETHOD(Close)();
|
||||
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
|
||||
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback);
|
||||
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
|
||||
STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
|
||||
STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
1160
7zip/Archive/Nsis/NsisIn.cpp
Executable file
1160
7zip/Archive/Nsis/NsisIn.cpp
Executable file
File diff suppressed because it is too large
Load Diff
166
7zip/Archive/Nsis/NsisIn.h
Executable file
166
7zip/Archive/Nsis/NsisIn.h
Executable file
@@ -0,0 +1,166 @@
|
||||
// Archive/NsisIn.h
|
||||
|
||||
#ifndef __ARCHIVE_ISO_IN_H
|
||||
#define __ARCHIVE_ISO_IN_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/Buffer.h"
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
#include "NsisDecode.h"
|
||||
|
||||
// #define NSIS_SCRIPT
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
const int kSignatureSize = 16;
|
||||
extern Byte kSignature[kSignatureSize];
|
||||
|
||||
const UInt32 kFlagsMask = 0xF;
|
||||
namespace NFlags
|
||||
{
|
||||
const UInt32 kUninstall = 1;
|
||||
const UInt32 kSilent = 2;
|
||||
const UInt32 kNoCrc = 4;
|
||||
const UInt32 kForceCrc = 8;
|
||||
}
|
||||
|
||||
struct CFirstHeader
|
||||
{
|
||||
UInt32 Flags;
|
||||
UInt32 HeaderLength;
|
||||
|
||||
UInt32 ArchiveSize;
|
||||
|
||||
bool ThereIsCrc() const
|
||||
{
|
||||
if ((Flags & NFlags::kForceCrc ) != 0)
|
||||
return true;
|
||||
return ((Flags & NFlags::kNoCrc) == 0);
|
||||
}
|
||||
|
||||
UInt32 GetDataSize() const { return ArchiveSize - (ThereIsCrc() ? 4 : 0); }
|
||||
};
|
||||
|
||||
|
||||
struct CBlockHeader
|
||||
{
|
||||
UInt32 Offset;
|
||||
UInt32 Num;
|
||||
};
|
||||
|
||||
struct CItem
|
||||
{
|
||||
AString Prefix;
|
||||
AString Name;
|
||||
UInt32 Pos;
|
||||
bool SizeIsDefined;
|
||||
bool CompressedSizeIsDefined;
|
||||
bool EstimatedSizeIsDefined;
|
||||
UInt32 Size;
|
||||
UInt32 CompressedSize;
|
||||
UInt32 EstimatedSize;
|
||||
FILETIME DateTime;
|
||||
UInt32 DictionarySize;
|
||||
bool IsCompressed;
|
||||
bool UseFilter;
|
||||
CItem(): UseFilter(false), SizeIsDefined(false), EstimatedSizeIsDefined(false),
|
||||
IsCompressed(true), CompressedSizeIsDefined(false), Size(0) {}
|
||||
|
||||
bool IsINSTDIR() const
|
||||
{
|
||||
if (Prefix.Length() < 3)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
AString GetReducedName() const
|
||||
{
|
||||
AString prefix = Prefix;
|
||||
if (prefix.Length() > 0)
|
||||
if (prefix[prefix.Length() - 1] != '\\')
|
||||
prefix += '\\';
|
||||
AString s2 = prefix + Name;
|
||||
const int len = 9;
|
||||
if (s2.Left(len).CompareNoCase("$INSTDIR\\") == 0)
|
||||
s2 = s2.Mid(len);
|
||||
return s2;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CInArchive
|
||||
{
|
||||
UInt64 _archiveSize;
|
||||
CMyComPtr<IInStream> _stream;
|
||||
|
||||
Byte ReadByte();
|
||||
UInt32 ReadUInt32();
|
||||
HRESULT Open2();
|
||||
void ReadBlockHeader(CBlockHeader &bh);
|
||||
AString ReadString(UInt32 pos);
|
||||
AString ReadString2(UInt32 pos);
|
||||
HRESULT ReadEntries(const CBlockHeader &bh);
|
||||
HRESULT Parse();
|
||||
|
||||
CByteBuffer _data;
|
||||
UInt64 _size;
|
||||
|
||||
size_t _posInData;
|
||||
|
||||
UInt32 _stringsPos;
|
||||
|
||||
|
||||
bool _headerIsCompressed;
|
||||
UInt32 _nonSolidStartOffset;
|
||||
public:
|
||||
HRESULT Open(IInStream *inStream, const UInt64 *maxCheckStartPosition);
|
||||
void Clear();
|
||||
|
||||
UInt64 StreamOffset;
|
||||
CDecoder Decoder;
|
||||
CObjectVector<CItem> Items;
|
||||
bool IsSolid;
|
||||
CFirstHeader FirstHeader;
|
||||
NMethodType::EEnum Method;
|
||||
bool UseFilter;
|
||||
UInt32 DictionarySize;
|
||||
bool FilterFlag;
|
||||
|
||||
#ifdef NSIS_SCRIPT
|
||||
AString Script;
|
||||
#endif
|
||||
UInt32 GetOffset() const { return IsSolid ? 4 : 0; }
|
||||
UInt64 GetDataPos(int index)
|
||||
{
|
||||
const CItem &item = Items[index];
|
||||
return GetOffset() + FirstHeader.HeaderLength + item.Pos;
|
||||
}
|
||||
|
||||
UInt64 GetPosOfSolidItem(int index) const
|
||||
{
|
||||
const CItem &item = Items[index];
|
||||
return 4 + FirstHeader.HeaderLength + item.Pos;
|
||||
}
|
||||
|
||||
UInt64 GetPosOfNonSolidItem(int index) const
|
||||
{
|
||||
const CItem &item = Items[index];
|
||||
return StreamOffset + _nonSolidStartOffset + 4 + item.Pos;
|
||||
}
|
||||
|
||||
void Release()
|
||||
{
|
||||
Decoder.Release();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
UInt32 GetUInt32FromMemLE(const Byte *p);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
3
7zip/Archive/Nsis/StdAfx.cpp
Executable file
3
7zip/Archive/Nsis/StdAfx.cpp
Executable file
@@ -0,0 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
9
7zip/Archive/Nsis/StdAfx.h
Executable file
9
7zip/Archive/Nsis/StdAfx.h
Executable file
@@ -0,0 +1,9 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
#include "../../../Common/NewHandler.h"
|
||||
|
||||
#endif
|
||||
67
7zip/Archive/Nsis/makefile
Executable file
67
7zip/Archive/Nsis/makefile
Executable file
@@ -0,0 +1,67 @@
|
||||
PROG = nsis.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
TAR_OBJS = \
|
||||
$O\DllExports.obj \
|
||||
$O\NsisDecode.obj \
|
||||
$O\NsisHandler.obj \
|
||||
$O\NsisIn.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\NewHandler.obj \
|
||||
$O\String.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\Vector.obj \
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\DLL.obj \
|
||||
$O\FileFind.obj \
|
||||
$O\PropVariant.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\LimitedStreams.obj \
|
||||
$O\ProgressUtils.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CodecsPath.obj \
|
||||
$O\CoderLoader.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\FilterCoder.obj \
|
||||
|
||||
7Z_OBJS = \
|
||||
$O\7zMethodID.obj \
|
||||
$O\7zMethods.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(TAR_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(AR_COMMON_OBJS) \
|
||||
$(7Z_OBJS) \
|
||||
$(COMPRESS_TAR_OBJS) \
|
||||
$O\CopyCoder.obj \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
$(TAR_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(AR_COMMON_OBJS): ../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7Z_OBJS): ../7z/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
|
||||
$(COMPL)
|
||||
3
7zip/Archive/Nsis/resource.rc
Executable file
3
7zip/Archive/Nsis/resource.rc
Executable file
@@ -0,0 +1,3 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("Nsis Plugin", "nsis")
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "../Common/CoderLoader.h"
|
||||
#include "../Common/CodecsPath.h"
|
||||
#include "../Common/FilterCoder.h"
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
|
||||
#include "../7z/7zMethods.h"
|
||||
|
||||
@@ -186,11 +187,15 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
UString u;
|
||||
if (item.HasUnicodeName() && !item.UnicodeName.IsEmpty())
|
||||
propVariant = item.UnicodeName;
|
||||
u = item.UnicodeName;
|
||||
else
|
||||
propVariant = (const wchar_t *)MultiByteToUnicodeString(item.Name, CP_OEMCP);
|
||||
u = MultiByteToUnicodeString(item.Name, CP_OEMCP);
|
||||
propVariant = (const wchar_t *)NItemName::WinNameToOSName(u);
|
||||
break;
|
||||
}
|
||||
case kpidIsFolder:
|
||||
propVariant = item.IsDirectory();
|
||||
break;
|
||||
|
||||
@@ -60,4 +60,4 @@ private:
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -18,4 +18,4 @@ public:
|
||||
|
||||
static CMarkerInitializer markerInitializer;
|
||||
|
||||
}}}
|
||||
}}}
|
||||
|
||||
@@ -149,7 +149,6 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
Close();
|
||||
if (openArchiveCallback == 0)
|
||||
return S_FALSE;
|
||||
bool mustBeClosed = true;
|
||||
// try
|
||||
{
|
||||
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
|
||||
|
||||
@@ -59,4 +59,4 @@ private:
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -77,7 +77,6 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
|
||||
IArchiveOpenCallback *openArchiveCallback)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
bool mustBeClosed = true;
|
||||
// try
|
||||
{
|
||||
CInArchive archive;
|
||||
|
||||
@@ -100,7 +100,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
updateItem.Name += '/';
|
||||
|
||||
if(!FileTimeToUnixTime(utcTime, updateItem.Time))
|
||||
return E_INVALIDARG;
|
||||
{
|
||||
updateItem.Time = 0;
|
||||
// return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
if (IntToBool(newData))
|
||||
{
|
||||
|
||||
@@ -140,7 +140,6 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
|
||||
cur += 8;
|
||||
|
||||
item.LinkFlag = *cur++;
|
||||
Byte linkFlag = item.LinkFlag;
|
||||
|
||||
ReadString(cur, NFileHeader::kNameSize, item.LinkName);
|
||||
cur += NFileHeader::kNameSize;
|
||||
|
||||
@@ -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 "ZIP_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZIP_EXPORTS" /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 "ZIP_EXPORTS" /D "COMPRESS_MT" /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 "ZIP_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 "ZIP_EXPORTS" /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 "ZIP_EXPORTS" /D "COMPRESS_MT" /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"
|
||||
@@ -268,6 +268,14 @@ SOURCE=..\Common\OutStreamWithCRC.cpp
|
||||
|
||||
SOURCE=..\Common\OutStreamWithCRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7zip common"
|
||||
|
||||
|
||||
@@ -198,34 +198,53 @@ HRESULT CAddCommon::Compress(ISequentialInStream *inStream, IOutStream *outStrea
|
||||
if (method == NFileHeader::NCompressionMethod::kDeflated ||
|
||||
method == NFileHeader::NCompressionMethod::kDeflated64)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant properties[2] =
|
||||
NWindows::NCOM::CPropVariant properties[] =
|
||||
{
|
||||
_options.NumPasses,
|
||||
_options.NumFastBytes
|
||||
_options.NumFastBytes,
|
||||
_options.NumMatchFinderCycles
|
||||
};
|
||||
PROPID propIDs[2] =
|
||||
PROPID propIDs[] =
|
||||
{
|
||||
NCoderPropID::kNumPasses,
|
||||
NCoderPropID::kNumFastBytes
|
||||
NCoderPropID::kNumFastBytes,
|
||||
NCoderPropID::kMatchFinderCycles
|
||||
};
|
||||
int numProps = sizeof(propIDs) / sizeof(propIDs[0]);
|
||||
if (!_options.NumMatchFinderCyclesDefined)
|
||||
numProps--;
|
||||
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
|
||||
RINOK(_compressEncoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties));
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, 2));
|
||||
} else if (method == NFileHeader::NCompressionMethod::kBZip2)
|
||||
_compressEncoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties);
|
||||
if (setCoderProperties)
|
||||
{
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, numProps));
|
||||
}
|
||||
}
|
||||
else if (method == NFileHeader::NCompressionMethod::kBZip2)
|
||||
{
|
||||
NWindows::NCOM::CPropVariant properties[1] =
|
||||
NWindows::NCOM::CPropVariant properties[] =
|
||||
{
|
||||
_options.DicSize,
|
||||
_options.NumPasses
|
||||
#ifdef COMPRESS_MT
|
||||
, _options.NumThreads
|
||||
#endif
|
||||
};
|
||||
PROPID propIDs[1] =
|
||||
PROPID propIDs[] =
|
||||
{
|
||||
NCoderPropID::kNumPasses,
|
||||
NCoderPropID::kDictionarySize,
|
||||
NCoderPropID::kNumPasses
|
||||
#ifdef COMPRESS_MT
|
||||
, NCoderPropID::kNumThreads
|
||||
#endif
|
||||
};
|
||||
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
|
||||
RINOK(_compressEncoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties));
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, 1));
|
||||
_compressEncoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties);
|
||||
if (setCoderProperties)
|
||||
{
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, sizeof(propIDs) / sizeof(propIDs[0])));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
CMyComPtr<ISequentialOutStream> outStreamNew;
|
||||
if (_options.PasswordIsDefined)
|
||||
|
||||
@@ -15,8 +15,15 @@ struct CCompressionMethodMode
|
||||
// bool MaximizeRatio;
|
||||
UInt32 NumPasses;
|
||||
UInt32 NumFastBytes;
|
||||
bool NumMatchFinderCyclesDefined;
|
||||
UInt32 NumMatchFinderCycles;
|
||||
UInt32 DicSize;
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 NumThreads;
|
||||
#endif
|
||||
bool PasswordIsDefined;
|
||||
AString Password;
|
||||
CCompressionMethodMode(): NumMatchFinderCyclesDefined(false) {}
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -539,13 +539,27 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
}
|
||||
ICompressCoder *coder = methodItems[m].Coder;
|
||||
|
||||
CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
|
||||
if (coder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&compressSetDecoderProperties) == S_OK)
|
||||
{
|
||||
Byte properties = (Byte)item.Flags;
|
||||
RINOK(compressSetDecoderProperties->SetDecoderProperties2(&properties, 1));
|
||||
CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
|
||||
coder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
|
||||
if (setDecoderProperties)
|
||||
{
|
||||
Byte properties = (Byte)item.Flags;
|
||||
RINOK(setDecoderProperties->SetDecoderProperties2(&properties, 1));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
||||
coder->QueryInterface(IID_ICompressSetCoderMt, (void **)&setCoderMt);
|
||||
if (setCoderMt)
|
||||
{
|
||||
RINOK(setCoderMt->SetNumberOfThreads(_numThreads));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// case NFileHeader::NCompressionMethod::kImploded:
|
||||
// switch(item.CompressionMethod)
|
||||
try
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
#include "ZipIn.h"
|
||||
#include "ZipCompressionMode.h"
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
namespace NArchive {
|
||||
namespace NZip {
|
||||
|
||||
@@ -61,14 +65,28 @@ private:
|
||||
|
||||
int m_Level;
|
||||
int m_MainMethod;
|
||||
UInt32 m_DicSize;
|
||||
UInt32 m_NumPasses;
|
||||
UInt32 m_NumFastBytes;
|
||||
UInt32 m_NumMatchFinderCycles;
|
||||
bool m_NumMatchFinderCyclesDefined;
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 _numThreads;
|
||||
#endif
|
||||
|
||||
void InitMethodProperties()
|
||||
{
|
||||
m_Level = -1;
|
||||
m_MainMethod = -1;
|
||||
m_NumPasses = 0xFFFFFFFF;
|
||||
m_NumFastBytes = 0xFFFFFFFF;
|
||||
m_DicSize =
|
||||
m_NumPasses =
|
||||
m_NumFastBytes =
|
||||
m_NumMatchFinderCycles = 0xFFFFFFFF;
|
||||
m_NumMatchFinderCyclesDefined = false;
|
||||
#ifdef COMPRESS_MT
|
||||
_numThreads = NWindows::NSystem::GetNumberOfProcessors();;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../Common/ItemNameUtils.h"
|
||||
#include "../Common/ParseProperties.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NCOM;
|
||||
@@ -22,15 +23,21 @@ using namespace NTime;
|
||||
namespace NArchive {
|
||||
namespace NZip {
|
||||
|
||||
static const UInt32 kNumDeflatePassesX1 = 1;
|
||||
static const UInt32 kNumDeflatePassesX7 = 3;
|
||||
|
||||
static const UInt32 kNumBZip2PassesX1 = 1;
|
||||
static const UInt32 kNumBZip2PassesX7 = 2;
|
||||
static const UInt32 kNumBZip2PassesX9 = 7;
|
||||
static const UInt32 kDeflateNumPassesX1 = 1;
|
||||
static const UInt32 kDeflateNumPassesX7 = 3;
|
||||
static const UInt32 kDeflateNumPassesX9 = 10;
|
||||
|
||||
static const UInt32 kNumFastBytesX1 = 32;
|
||||
static const UInt32 kNumFastBytesX7 = 64;
|
||||
static const UInt32 kNumFastBytesX9 = 128;
|
||||
|
||||
static const UInt32 kBZip2NumPassesX1 = 1;
|
||||
static const UInt32 kBZip2NumPassesX7 = 2;
|
||||
static const UInt32 kBZip2NumPassesX9 = 7;
|
||||
|
||||
static const UInt32 kBZip2DicSizeX1 = 100000;
|
||||
static const UInt32 kBZip2DicSizeX3 = 500000;
|
||||
static const UInt32 kBZip2DicSizeX5 = 900000;
|
||||
|
||||
STDMETHODIMP CHandler::GetFileTimeType(UInt32 *timeType)
|
||||
{
|
||||
@@ -59,7 +66,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
updateItem.NewData = IntToBool(newData);
|
||||
updateItem.IndexInArchive = indexInArchive;
|
||||
updateItem.IndexInClient = i;
|
||||
bool existInArchive = (indexInArchive != UInt32(-1));
|
||||
// bool existInArchive = (indexInArchive != UInt32(-1));
|
||||
if (IntToBool(newProperties))
|
||||
{
|
||||
FILETIME utcFileTime;
|
||||
@@ -109,7 +116,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
if(!FileTimeToLocalFileTime(&utcFileTime, &localFileTime))
|
||||
return E_INVALIDARG;
|
||||
if(!FileTimeToDosTime(localFileTime, updateItem.Time))
|
||||
return E_INVALIDARG;
|
||||
{
|
||||
// return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (!isDirectoryStatusDefined)
|
||||
updateItem.IsDirectory = ((updateItem.Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
|
||||
@@ -200,20 +209,34 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
(mainMethod == NFileHeader::NCompressionMethod::kDeflated64);
|
||||
bool isBZip2 = (mainMethod == NFileHeader::NCompressionMethod::kBZip2);
|
||||
options.NumPasses = m_NumPasses;
|
||||
if (options.NumPasses == 0xFFFFFFFF)
|
||||
{
|
||||
if (isDeflate)
|
||||
options.NumPasses = (level >= 7 ? kNumDeflatePassesX7 : kNumDeflatePassesX1);
|
||||
else if (isBZip2)
|
||||
options.NumPasses = (level >= 9 ? kNumBZip2PassesX9 :
|
||||
(level >= 7 ? kNumBZip2PassesX7 : kNumBZip2PassesX1));
|
||||
}
|
||||
|
||||
options.DicSize = m_DicSize;
|
||||
options.NumFastBytes = m_NumFastBytes;
|
||||
if (options.NumFastBytes == 0xFFFFFFFF)
|
||||
options.NumMatchFinderCycles = m_NumMatchFinderCycles;
|
||||
options.NumMatchFinderCyclesDefined = m_NumMatchFinderCyclesDefined;
|
||||
#ifdef COMPRESS_MT
|
||||
options.NumThreads = _numThreads;
|
||||
#endif
|
||||
if (isDeflate)
|
||||
{
|
||||
if (isDeflate)
|
||||
options.NumFastBytes = (level >= 7 ? kNumFastBytesX7 : kNumFastBytesX1);
|
||||
if (options.NumPasses == 0xFFFFFFFF)
|
||||
options.NumPasses = (level >= 9 ? kDeflateNumPassesX9 :
|
||||
(level >= 7 ? kDeflateNumPassesX7 :
|
||||
kDeflateNumPassesX1));
|
||||
if (options.NumFastBytes == 0xFFFFFFFF)
|
||||
options.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
|
||||
(level >= 7 ? kNumFastBytesX7 :
|
||||
kNumFastBytesX1));
|
||||
}
|
||||
if (isBZip2)
|
||||
{
|
||||
if (options.NumPasses == 0xFFFFFFFF)
|
||||
options.NumPasses = (level >= 9 ? kBZip2NumPassesX9 :
|
||||
(level >= 7 ? kBZip2NumPassesX7 :
|
||||
kBZip2NumPassesX1));
|
||||
if (options.DicSize == 0xFFFFFFFF)
|
||||
options.DicSize = (level >= 5 ? kBZip2DicSizeX5 :
|
||||
(level >= 3 ? kBZip2DicSizeX3 :
|
||||
kBZip2DicSizeX1));
|
||||
}
|
||||
|
||||
return Update(m_Items, updateItems, outStream,
|
||||
@@ -223,45 +246,32 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
|
||||
{
|
||||
#ifdef COMPRESS_MT
|
||||
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
|
||||
_numThreads = numProcessors;
|
||||
#endif
|
||||
InitMethodProperties();
|
||||
for (int i = 0; i < numProperties; i++)
|
||||
{
|
||||
UString name = UString(names[i]);
|
||||
name.MakeUpper();
|
||||
const PROPVARIANT &value = values[i];
|
||||
if (name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (name[0] == 'X')
|
||||
const PROPVARIANT &prop = values[i];
|
||||
|
||||
if (name[0] == L'X')
|
||||
{
|
||||
name.Delete(0);
|
||||
UInt32 level = 9;
|
||||
if (value.vt == VT_UI4)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
level = value.ulVal;
|
||||
}
|
||||
else if (value.vt == VT_EMPTY)
|
||||
{
|
||||
if(!name.IsEmpty())
|
||||
{
|
||||
const wchar_t *start = name;
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(start, &end);
|
||||
if (end - start != name.Length())
|
||||
return E_INVALIDARG;
|
||||
level = (UInt32)v;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
m_Level = (level <= 9) ? (int)level: 9;
|
||||
RINOK(ParsePropValue(name.Mid(1), prop, level));
|
||||
m_Level = level;
|
||||
continue;
|
||||
}
|
||||
else if (name == L"M")
|
||||
{
|
||||
if (value.vt == VT_BSTR)
|
||||
if (prop.vt == VT_BSTR)
|
||||
{
|
||||
UString valueString = value.bstrVal;
|
||||
UString valueString = prop.bstrVal;
|
||||
valueString.MakeUpper();
|
||||
if (valueString == L"COPY")
|
||||
m_MainMethod = NFileHeader::NCompressionMethod::kStored;
|
||||
@@ -274,15 +284,15 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
else if (value.vt == VT_UI4)
|
||||
else if (prop.vt == VT_UI4)
|
||||
{
|
||||
switch(value.ulVal)
|
||||
switch(prop.ulVal)
|
||||
{
|
||||
case NFileHeader::NCompressionMethod::kStored:
|
||||
case NFileHeader::NCompressionMethod::kDeflated:
|
||||
case NFileHeader::NCompressionMethod::kDeflated64:
|
||||
case NFileHeader::NCompressionMethod::kBZip2:
|
||||
m_MainMethod = (Byte)value.ulVal;
|
||||
m_MainMethod = (Byte)prop.ulVal;
|
||||
break;
|
||||
default:
|
||||
return E_INVALIDARG;
|
||||
@@ -291,25 +301,38 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
else if (name == L"PASS")
|
||||
else if (name[0] == L'D')
|
||||
{
|
||||
if (value.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
if (value.ulVal < 1 || value.ulVal > 10)
|
||||
return E_INVALIDARG;
|
||||
m_NumPasses = value.ulVal;
|
||||
UInt32 dicSize = kBZip2DicSizeX5;
|
||||
RINOK(ParsePropDictionaryValue(name.Mid(1), prop, dicSize));
|
||||
m_DicSize = dicSize;
|
||||
}
|
||||
else if (name == L"FB")
|
||||
else if (name.Left(4) == L"PASS")
|
||||
{
|
||||
if (value.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
/*
|
||||
if (value.ulVal < 3 || value.ulVal > 255)
|
||||
return E_INVALIDARG;
|
||||
*/
|
||||
m_NumFastBytes = value.ulVal;
|
||||
UInt32 num = kDeflateNumPassesX9;
|
||||
RINOK(ParsePropValue(name.Mid(4), prop, num));
|
||||
m_NumPasses = num;
|
||||
}
|
||||
else
|
||||
else if (name.Left(2) == L"FB")
|
||||
{
|
||||
UInt32 num = kNumFastBytesX9;
|
||||
RINOK(ParsePropValue(name.Mid(2), prop, num));
|
||||
m_NumFastBytes = num;
|
||||
}
|
||||
else if (name.Left(2) == L"MC")
|
||||
{
|
||||
UInt32 num = 0xFFFFFFFF;
|
||||
RINOK(ParsePropValue(name.Mid(2), prop, num));
|
||||
m_NumMatchFinderCycles = num;
|
||||
m_NumMatchFinderCyclesDefined = true;
|
||||
}
|
||||
else if (name.Left(2) == L"MT")
|
||||
{
|
||||
#ifdef COMPRESS_MT
|
||||
RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
@@ -167,7 +167,7 @@ static HRESULT UpdateOneFile(IInStream *inStream,
|
||||
}
|
||||
}
|
||||
}
|
||||
fileHeader.SetEncrypted(options.PasswordIsDefined);
|
||||
fileHeader.SetEncrypted(!isDirectory && options.PasswordIsDefined);
|
||||
/*
|
||||
fileHeader.CommentSize = (updateItem.Commented) ?
|
||||
WORD(updateItem.CommentRange.Size) : 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
PROG = zip.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
ZIP_OBJS = \
|
||||
@@ -47,6 +47,7 @@ AR_COMMON_OBJS = \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
7Z_OBJS = \
|
||||
$O\7zMethodID.obj \
|
||||
|
||||
@@ -44,4 +44,4 @@ private:
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,9 @@ DIRS = \
|
||||
Cpio\~ \
|
||||
Deb\~ \
|
||||
GZip\~ \
|
||||
Iso\~ \
|
||||
Lzh\~ \
|
||||
Nsis\~ \
|
||||
Rar\~ \
|
||||
RPM\~ \
|
||||
Split\~ \
|
||||
|
||||
@@ -44,7 +44,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -69,7 +69,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -94,7 +94,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -121,7 +121,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "FORMAT_Z" /D "FORMAT_SPLIT" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_DEFLATE64" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -1652,6 +1652,14 @@ SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
|
||||
|
||||
SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ParseProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "split"
|
||||
|
||||
@@ -1763,6 +1771,14 @@ SOURCE=..\..\UI\Common\PropIDUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\UI\Common\SetProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\UI\Common\SetProperties.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\UI\Common\SortUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -11,9 +11,11 @@ CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DFORMAT_TAR \
|
||||
-DFORMAT_Z \
|
||||
-DFORMAT_ZIP \
|
||||
-DCOMPRESS_MT \
|
||||
-DCOMPRESS_BCJ_X86 \
|
||||
-DCOMPRESS_BCJ2 \
|
||||
-DCOMPRESS_BZIP2 \
|
||||
-DCOMPRESS_BZIP2_MT \
|
||||
-DCOMPRESS_COPY \
|
||||
-DCOMPRESS_DEFLATE \
|
||||
-DCOMPRESS_DEFLATE64 \
|
||||
@@ -93,6 +95,7 @@ UI_COMMON_OBJS = \
|
||||
$O\ExtractingFilePath.obj \
|
||||
$O\OpenArchive.obj \
|
||||
$O\PropIDUtils.obj \
|
||||
$O\SetProperties.obj \
|
||||
$O\SortUtils.obj \
|
||||
$O\TempFiles.obj \
|
||||
$O\Update.obj \
|
||||
@@ -112,6 +115,7 @@ AR_COMMON_OBJS = \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\MultiStream.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
|
||||
7Z_OBJS = \
|
||||
|
||||
@@ -6,6 +6,7 @@ CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DNO_REGISTRY \
|
||||
-D_NO_CRYPTO \
|
||||
-DFORMAT_7Z \
|
||||
-DCOMPRESS_MT \
|
||||
-DCOMPRESS_BCJ_X86 \
|
||||
-DCOMPRESS_BCJ2 \
|
||||
-DCOMPRESS_COPY \
|
||||
@@ -78,6 +79,7 @@ UI_COMMON_OBJS = \
|
||||
$O\ExtractingFilePath.obj \
|
||||
$O\OpenArchive.obj \
|
||||
$O\PropIDUtils.obj \
|
||||
$O\SetProperties.obj \
|
||||
$O\SortUtils.obj \
|
||||
$O\TempFiles.obj \
|
||||
$O\Update.obj \
|
||||
@@ -97,6 +99,7 @@ AR_COMMON_OBJS = \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\MultiStream.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
|
||||
7Z_OBJS = \
|
||||
|
||||
@@ -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 /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /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 "..\..\..\..\SDK" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\SDK" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /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"
|
||||
@@ -292,6 +292,14 @@ SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
|
||||
|
||||
SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ParseProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
|
||||
@@ -5,9 +5,11 @@ CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DEXCLUDE_COM \
|
||||
-DNO_REGISTRY \
|
||||
-DFORMAT_7Z \
|
||||
-DCOMPRESS_MT \
|
||||
-DCOMPRESS_BCJ_X86 \
|
||||
-DCOMPRESS_BCJ2 \
|
||||
-DCOMPRESS_BZIP2_DECODER \
|
||||
-DCOMPRESS_BZIP2_MT \
|
||||
-DCOMPRESS_COPY \
|
||||
-DCOMPRESS_DEFLATE_DECODER \
|
||||
-DCOMPRESS_LZMA \
|
||||
@@ -54,6 +56,7 @@ AR_COMMON_OBJS = \
|
||||
$O\InStreamWithCRC.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
|
||||
7Z_OBJS = \
|
||||
|
||||
@@ -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 /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "EXTRACT_ONLY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "EXTRACT_ONLY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /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 "..\..\..\..\SDK" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "EXTRACT_ONLY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\SDK" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "EXTRACT_ONLY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_MT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE_DECODER" /D "COMPRESS_BZIP2_DECODER" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /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"
|
||||
@@ -288,6 +288,14 @@ SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
|
||||
|
||||
SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ParseProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
|
||||
@@ -6,9 +6,11 @@ CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DNO_REGISTRY \
|
||||
-DEXTRACT_ONLY \
|
||||
-DFORMAT_7Z \
|
||||
-DCOMPRESS_MT \
|
||||
-DCOMPRESS_BCJ_X86 \
|
||||
-DCOMPRESS_BCJ2 \
|
||||
-DCOMPRESS_BZIP2_DECODER \
|
||||
-DCOMPRESS_BZIP2_MT \
|
||||
-DCOMPRESS_COPY \
|
||||
-DCOMPRESS_DEFLATE_DECODER \
|
||||
-DCOMPRESS_LZMA \
|
||||
@@ -54,6 +56,7 @@ AR_COMMON_OBJS = \
|
||||
$O\FilterCoder.obj \
|
||||
$O\ItemNameUtils.obj \
|
||||
$O\OutStreamWithCRC.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
|
||||
7Z_OBJS = \
|
||||
|
||||
@@ -40,7 +40,10 @@ static const char *kCopyrightString =
|
||||
|
||||
static const int kNumSwitches = 6;
|
||||
|
||||
const wchar_t *defaultExt = L".exe";
|
||||
#ifdef _WIN32
|
||||
static const wchar_t *kDefaultExt = L".exe";
|
||||
static const int kDefaultExtLength = 4;
|
||||
#endif
|
||||
|
||||
namespace NKey {
|
||||
enum Enum
|
||||
@@ -383,8 +386,10 @@ int Main2(
|
||||
|
||||
bool yesToAll = parser[NKey::kYes].ThereIs;
|
||||
|
||||
if (archiveName.Right(4).CompareNoCase(defaultExt) != 0)
|
||||
archiveName += defaultExt;
|
||||
#ifdef _WIN32
|
||||
if (archiveName.Right(kDefaultExtLength).CompareNoCase(kDefaultExt) != 0)
|
||||
archiveName += kDefaultExt;
|
||||
#endif
|
||||
|
||||
// NExtractMode::EEnum extractMode;
|
||||
// bool isExtractGroupCommand = command.IsFromExtractGroup(extractMode);
|
||||
@@ -459,7 +464,7 @@ int Main2(
|
||||
HRESULT result = ListArchives(
|
||||
v1, v2,
|
||||
wildcardCensorHead,
|
||||
true,
|
||||
true, false,
|
||||
passwordEnabled,
|
||||
password);
|
||||
if (result != S_OK)
|
||||
|
||||
@@ -23,9 +23,9 @@ static LPCWSTR kErrorTitle = L"7-Zip";
|
||||
static LPCWSTR kCantDeleteFile = L"Can not delete output file";
|
||||
static LPCWSTR kCantOpenFile = L"Can not open output file";
|
||||
static LPCWSTR kUnsupportedMethod = L"Unsupported Method";
|
||||
static LPCWSTR kCRCFailed = L"CRC Failed";
|
||||
static LPCWSTR kDataError = L"Data Error";
|
||||
// static LPCTSTR kUnknownError = TEXT("Unknown Error");
|
||||
// static LPCWSTR kCRCFailed = L"CRC Failed";
|
||||
// static LPCWSTR kDataError = L"Data Error";
|
||||
// static LPCWSTR kUnknownError = L""Unknown Error";
|
||||
|
||||
void CExtractCallbackImp::Init(IInArchive *archiveHandler,
|
||||
const UString &directoryPath,
|
||||
@@ -33,7 +33,8 @@ void CExtractCallbackImp::Init(IInArchive *archiveHandler,
|
||||
const FILETIME &utcLastWriteTimeDefault,
|
||||
UInt32 attributesDefault)
|
||||
{
|
||||
_numErrors = 0;
|
||||
_message.Empty();
|
||||
_isCorrupt = false;
|
||||
_itemDefaultName = itemDefaultName;
|
||||
_utcLastWriteTimeDefault = utcLastWriteTimeDefault;
|
||||
_attributesDefault = attributesDefault;
|
||||
@@ -170,14 +171,8 @@ STDMETHODIMP CExtractCallbackImp::GetStream(UInt32 index,
|
||||
{
|
||||
if (!NDirectory::DeleteFileAlways(fullProcessedPath))
|
||||
{
|
||||
#ifdef _SILENT
|
||||
_message = kCantDeleteFile;
|
||||
#else
|
||||
MessageBoxW(0, kCantDeleteFile, kErrorTitle, 0);
|
||||
#endif
|
||||
// g_StdOut << GetOemString(fullProcessedPath);
|
||||
// return E_ABORT;
|
||||
return E_ABORT;
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,12 +182,8 @@ STDMETHODIMP CExtractCallbackImp::GetStream(UInt32 index,
|
||||
CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
|
||||
if (!_outFileStreamSpec->Create(fullProcessedPath, true))
|
||||
{
|
||||
#ifdef _SILENT
|
||||
_message = kCantOpenFile;
|
||||
#else
|
||||
MessageBoxW(0, kCantOpenFile, kErrorTitle, 0);
|
||||
#endif
|
||||
return E_ABORT;
|
||||
return E_FAIL;
|
||||
}
|
||||
_outFileStream = outStreamLoc;
|
||||
*outStream = outStreamLoc.Detach();
|
||||
@@ -228,30 +219,23 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 resultEOperationResul
|
||||
}
|
||||
default:
|
||||
{
|
||||
_numErrors++;
|
||||
UString errorMessage;
|
||||
_outFileStream.Release();
|
||||
switch(resultEOperationResult)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
|
||||
errorMessage = kUnsupportedMethod;
|
||||
_message = kUnsupportedMethod;
|
||||
break;
|
||||
case NArchive::NExtract::NOperationResult::kCRCError:
|
||||
errorMessage = kCRCFailed;
|
||||
_isCorrupt = true;
|
||||
// _message = kCRCFailed;
|
||||
break;
|
||||
case NArchive::NExtract::NOperationResult::kDataError:
|
||||
errorMessage = kDataError;
|
||||
_isCorrupt = true;
|
||||
// _message = kDataError;
|
||||
break;
|
||||
/*
|
||||
default:
|
||||
errorMessage = kUnknownError;
|
||||
*/
|
||||
_isCorrupt = true;
|
||||
}
|
||||
#ifdef _SILENT
|
||||
_message = errorMessage;
|
||||
#else
|
||||
MessageBoxW(0, errorMessage, kErrorTitle, 0);
|
||||
#endif
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
@@ -263,4 +247,3 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 resultEOperationResul
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,15 +11,12 @@
|
||||
#include "../../Archive/IArchive.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
// #include "../../Common/ZipSettings.h"
|
||||
#include "../../ICoder.h"
|
||||
|
||||
#ifndef _NO_PROGRESS
|
||||
#include "../../FileManager/Resource/ProgressDialog/ProgressDialog.h"
|
||||
#endif
|
||||
|
||||
// #include "../../Explorer/MyMessages.h"
|
||||
|
||||
class CExtractCallbackImp:
|
||||
public IArchiveExtractCallback,
|
||||
public CMyUnknownImp
|
||||
@@ -67,9 +64,8 @@ public:
|
||||
CProgressDialog ProgressDialog;
|
||||
#endif
|
||||
|
||||
#ifdef _SILENT
|
||||
bool _isCorrupt;
|
||||
UString _message;
|
||||
#endif
|
||||
|
||||
void Init(IInArchive *archiveHandler,
|
||||
const UString &directoryPath,
|
||||
@@ -77,8 +73,6 @@ public:
|
||||
const FILETIME &utcLastWriteTimeDefault,
|
||||
UInt32 attributesDefault);
|
||||
|
||||
UInt64 _numErrors;
|
||||
|
||||
#ifndef _NO_PROGRESS
|
||||
HRESULT StartProgressDialog(const UString &title)
|
||||
{
|
||||
@@ -92,7 +86,6 @@ public:
|
||||
}
|
||||
|
||||
ProgressDialog.Show(SW_SHOWNORMAL);
|
||||
// _progressDialog.Start(m_ParentWindow, PROGDLG_MODAL | PROGDLG_AUTOTIME);
|
||||
return S_OK;
|
||||
}
|
||||
virtual ~CExtractCallbackImp() { ProgressDialog.Destroy(); }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// ExtractEngine.h
|
||||
// ExtractEngine.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
@@ -21,7 +21,6 @@ using namespace NWindows;
|
||||
|
||||
struct CThreadExtracting
|
||||
{
|
||||
// CMyComPtr<IInArchive> ArchiveHandler;
|
||||
CArchiveLink ArchiveLink;
|
||||
|
||||
CExtractCallbackImp *ExtractCallbackSpec;
|
||||
@@ -29,12 +28,15 @@ struct CThreadExtracting
|
||||
|
||||
#ifndef _NO_PROGRESS
|
||||
HRESULT Result;
|
||||
|
||||
|
||||
HRESULT Extract()
|
||||
{
|
||||
return ArchiveLink.GetArchive()->Extract(0, (UInt32)-1 , BoolToInt(false), ExtractCallback);
|
||||
}
|
||||
DWORD Process()
|
||||
{
|
||||
ExtractCallbackSpec->ProgressDialog.WaitCreating();
|
||||
Result = ArchiveLink.GetArchive()->Extract(0, (UInt32)-1 , BoolToInt(false),
|
||||
ExtractCallback);
|
||||
Result = Extract();
|
||||
ExtractCallbackSpec->ProgressDialog.MyClose();
|
||||
return 0;
|
||||
}
|
||||
@@ -45,26 +47,22 @@ struct CThreadExtracting
|
||||
#endif
|
||||
};
|
||||
|
||||
static const LPCTSTR kCantFindArchive = TEXT("Can not find archive file");
|
||||
static const LPCTSTR kCantOpenArchive = TEXT("File is not correct archive");
|
||||
static const LPCWSTR kCantFindArchive = L"Can not find archive file";
|
||||
static const LPCWSTR kCantOpenArchive = L"File is not correct archive";
|
||||
|
||||
HRESULT ExtractArchive(
|
||||
const UString &fileName,
|
||||
const UString &folderName,
|
||||
COpenCallbackGUI *openCallback
|
||||
#ifdef _SILENT
|
||||
, UString &resultMessage
|
||||
#endif
|
||||
)
|
||||
COpenCallbackGUI *openCallback,
|
||||
bool showProgress,
|
||||
bool &isCorrupt,
|
||||
UString &errorMessage)
|
||||
{
|
||||
isCorrupt = false;
|
||||
NFile::NFind::CFileInfoW archiveFileInfo;
|
||||
if (!NFile::NFind::FindFile(fileName, archiveFileInfo))
|
||||
{
|
||||
#ifndef _SILENT
|
||||
MessageBox(0, kCantFindArchive, TEXT("7-Zip"), 0);
|
||||
#else
|
||||
resultMessage = kCantFindArchive;
|
||||
#endif
|
||||
errorMessage = kCantFindArchive;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
@@ -72,18 +70,10 @@ HRESULT ExtractArchive(
|
||||
|
||||
HRESULT result = MyOpenArchive(fileName, extracter.ArchiveLink, openCallback);
|
||||
|
||||
/*
|
||||
CArchiverInfo archiverInfoResult;
|
||||
int subExtIndex;
|
||||
HRESULT result = OpenArchive(fileName, &extracter.ArchiveHandler,
|
||||
archiverInfoResult, subExtIndex, NULL);
|
||||
*/
|
||||
if (result != S_OK)
|
||||
{
|
||||
#ifdef _SILENT
|
||||
resultMessage = kCantOpenArchive;
|
||||
#endif
|
||||
return E_FAIL;
|
||||
errorMessage = kCantOpenArchive;
|
||||
return result;
|
||||
}
|
||||
|
||||
UString directoryPath = folderName;
|
||||
@@ -105,54 +95,45 @@ HRESULT ExtractArchive(
|
||||
|
||||
if(!NFile::NDirectory::CreateComplexDirectory(directoryPath))
|
||||
{
|
||||
#ifndef _SILENT
|
||||
MyMessageBox(MyFormatNew(IDS_CANNOT_CREATE_FOLDER,
|
||||
errorMessage = MyFormatNew(IDS_CANNOT_CREATE_FOLDER,
|
||||
#ifdef LANG
|
||||
0x02000603,
|
||||
#endif
|
||||
directoryPath));
|
||||
#else
|
||||
resultMessage = TEXT("Can not create output folder");
|
||||
#endif
|
||||
directoryPath);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
extracter.ExtractCallbackSpec = new CExtractCallbackImp;
|
||||
extracter.ExtractCallback = extracter.ExtractCallbackSpec;
|
||||
|
||||
// anExtractCallBackSpec->StartProgressDialog();
|
||||
|
||||
// anExtractCallBackSpec->m_ProgressDialog.ShowWindow(SW_SHOWNORMAL);
|
||||
|
||||
extracter.ExtractCallbackSpec->Init(
|
||||
extracter.ArchiveLink.GetArchive(),
|
||||
directoryPath, L"Default", archiveFileInfo.LastWriteTime, 0);
|
||||
|
||||
#ifndef _NO_PROGRESS
|
||||
|
||||
CThread thread;
|
||||
if (!thread.Create(CThreadExtracting::MyThreadFunction, &extracter))
|
||||
throw 271824;
|
||||
if (showProgress)
|
||||
{
|
||||
CThread thread;
|
||||
if (!thread.Create(CThreadExtracting::MyThreadFunction, &extracter))
|
||||
throw 271824;
|
||||
|
||||
UString title;
|
||||
#ifdef LANG
|
||||
title = LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890);
|
||||
#else
|
||||
title = NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING);
|
||||
#endif
|
||||
extracter.ExtractCallbackSpec->StartProgressDialog(title);
|
||||
result = extracter.Result;
|
||||
}
|
||||
else
|
||||
|
||||
UString title;
|
||||
#ifdef LANG
|
||||
title = LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890);
|
||||
#else
|
||||
title = NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING);
|
||||
#endif
|
||||
extracter.ExtractCallbackSpec->StartProgressDialog(title);
|
||||
return extracter.Result;
|
||||
|
||||
#else
|
||||
|
||||
result = extracter.ArchiveHandler->Extract(0, (UInt32)-1,
|
||||
BoolToInt(false), extracter.ExtractCallback);
|
||||
#ifdef _SILENT
|
||||
resultMessage = extracter.ExtractCallbackSpec->_message;
|
||||
#endif
|
||||
{
|
||||
result = extracter.Extract();
|
||||
}
|
||||
errorMessage = extracter.ExtractCallbackSpec->_message;
|
||||
isCorrupt = extracter.ExtractCallbackSpec->_isCorrupt;
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,11 +9,9 @@
|
||||
HRESULT ExtractArchive(
|
||||
const UString &fileName,
|
||||
const UString &folderName,
|
||||
COpenCallbackGUI *openCallback
|
||||
#ifdef _SILENT
|
||||
, UString &resultMessage
|
||||
#endif
|
||||
);
|
||||
COpenCallbackGUI *openCallback,
|
||||
bool showProgress,
|
||||
bool &isCorrupt,
|
||||
UString &errorMessage);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/DLL.h"
|
||||
#include "Windows/ResourceString.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../../ICoder.h"
|
||||
@@ -24,13 +25,16 @@
|
||||
|
||||
#include "ExtractEngine.h"
|
||||
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#include "resource.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
|
||||
static LPCTSTR kTempDirPrefix = TEXT("7zS");
|
||||
|
||||
#define _SHELL_EXECUTE
|
||||
|
||||
static bool ReadDataString(LPCWSTR fileName, LPCSTR startID,
|
||||
LPCSTR endID, AString &stringResult)
|
||||
{
|
||||
@@ -143,17 +147,14 @@ int APIENTRY WinMain(
|
||||
InitCommonControls();
|
||||
|
||||
UString archiveName, switches;
|
||||
#ifdef _SHELL_EXECUTE
|
||||
UString executeFile, executeParameters;
|
||||
#endif
|
||||
NCommandLineParser::SplitCommandLine(GetCommandLineW(), archiveName, switches);
|
||||
|
||||
UString fullPath;
|
||||
NDLL::MyGetModuleFileName(g_hInstance, fullPath);
|
||||
|
||||
AString config;
|
||||
if (!ReadDataString(fullPath, kStartID, kEndID, config))
|
||||
{
|
||||
MyMessageBox(L"Can't load config info");
|
||||
return 1;
|
||||
}
|
||||
switches.Trim();
|
||||
bool assumeYes = false;
|
||||
if (switches.Left(2).CompareNoCase(UString(L"-y")) == 0)
|
||||
@@ -163,21 +164,34 @@ int APIENTRY WinMain(
|
||||
switches.Trim();
|
||||
}
|
||||
|
||||
#ifdef _SHELL_EXECUTE
|
||||
bool executeMode = false;
|
||||
#endif
|
||||
AString config;
|
||||
if (!ReadDataString(fullPath, kStartID, kEndID, config))
|
||||
{
|
||||
if (!assumeYes)
|
||||
MyMessageBox(L"Can't load config info");
|
||||
return 1;
|
||||
}
|
||||
|
||||
UString dirPrefix = L".\\";
|
||||
UString appLaunched;
|
||||
bool showProgress = true;
|
||||
if (!config.IsEmpty())
|
||||
{
|
||||
CObjectVector<CTextConfigPair> pairs;
|
||||
if (!GetTextConfig(config, pairs))
|
||||
{
|
||||
MyMessageBox(L"Config failed");
|
||||
if (!assumeYes)
|
||||
MyMessageBox(L"Config failed");
|
||||
return 1;
|
||||
}
|
||||
UString friendlyName = GetTextConfigValue(pairs, L"Title");
|
||||
UString installPrompt = GetTextConfigValue(pairs, L"BeginPrompt");
|
||||
|
||||
UString progress = GetTextConfigValue(pairs, L"Progress");
|
||||
if (progress.CompareNoCase(L"no") == 0)
|
||||
showProgress = false;
|
||||
int index = FindTextConfigItem(pairs, L"Directory");
|
||||
if (index >= 0)
|
||||
dirPrefix = pairs[index].String;
|
||||
if (!installPrompt.IsEmpty() && !assumeYes)
|
||||
{
|
||||
if (MessageBoxW(0, installPrompt, friendlyName, MB_YESNO |
|
||||
@@ -185,33 +199,41 @@ int APIENTRY WinMain(
|
||||
return 0;
|
||||
}
|
||||
appLaunched = GetTextConfigValue(pairs, L"RunProgram");
|
||||
#ifdef _SHELL_EXECUTE
|
||||
if (appLaunched.IsEmpty())
|
||||
{
|
||||
executeMode = true;
|
||||
appLaunched = GetTextConfigValue(pairs, L"Execute");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _SHELL_EXECUTE
|
||||
executeFile = GetTextConfigValue(pairs, L"ExecuteFile");
|
||||
executeParameters = GetTextConfigValue(pairs, L"ExecuteParameters") + switches;
|
||||
#endif
|
||||
}
|
||||
|
||||
NFile::NDirectory::CTempDirectory tempDir;
|
||||
if (!tempDir.Create(kTempDirPrefix))
|
||||
{
|
||||
MyMessageBox(L"Can not create temp folder archive");
|
||||
if (!assumeYes)
|
||||
MyMessageBox(L"Can not create temp folder archive");
|
||||
return 1;
|
||||
}
|
||||
|
||||
COpenCallbackGUI openCallback;
|
||||
|
||||
UString tempDirPath = GetUnicodeString(tempDir.GetPath());
|
||||
HRESULT result = ExtractArchive(fullPath, tempDirPath, &openCallback);
|
||||
bool isCorrupt = false;
|
||||
UString errorMessage;
|
||||
HRESULT result = ExtractArchive(fullPath, tempDirPath, &openCallback, showProgress,
|
||||
isCorrupt, errorMessage);
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
if (result == S_FALSE)
|
||||
MyMessageBox(L"Can not open archive");
|
||||
else if (result != E_ABORT)
|
||||
ShowErrorMessage(result);
|
||||
if (!assumeYes)
|
||||
{
|
||||
if (result == S_FALSE || isCorrupt)
|
||||
{
|
||||
errorMessage = NWindows::MyLoadStringW(IDS_EXTRACTION_ERROR_MESSAGE);
|
||||
result = E_FAIL;
|
||||
}
|
||||
if (result != E_ABORT && !errorMessage.IsEmpty())
|
||||
::MessageBoxW(0, errorMessage, NWindows::MyLoadStringW(IDS_EXTRACTION_ERROR_TITLE), MB_ICONERROR);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -220,30 +242,11 @@ int APIENTRY WinMain(
|
||||
if (!SetCurrentDirectory(tempDir.GetPath()))
|
||||
return 1;
|
||||
|
||||
if (appLaunched.IsEmpty())
|
||||
{
|
||||
appLaunched = L"setup.exe";
|
||||
if (!NFile::NFind::DoesFileExist(GetSystemString(appLaunched)))
|
||||
{
|
||||
MyMessageBox(L"Can not find setup.exe");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
UString s2 = tempDirPath;
|
||||
NFile::NName::NormalizeDirPathPrefix(s2);
|
||||
appLaunched.Replace(L"%%T\\", s2);
|
||||
}
|
||||
|
||||
appLaunched.Replace(L"%%T", tempDirPath);
|
||||
|
||||
|
||||
HANDLE hProcess = 0;
|
||||
#ifdef _SHELL_EXECUTE
|
||||
if (executeMode)
|
||||
if (!executeFile.IsEmpty())
|
||||
{
|
||||
CSysString filePath = GetSystemString(appLaunched);
|
||||
CSysString filePath = GetSystemString(executeFile);
|
||||
SHELLEXECUTEINFO execInfo;
|
||||
execInfo.cbSize = sizeof(execInfo);
|
||||
execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
|
||||
@@ -251,11 +254,14 @@ int APIENTRY WinMain(
|
||||
execInfo.lpVerb = NULL;
|
||||
execInfo.lpFile = filePath;
|
||||
|
||||
CSysString switchesSys = GetSystemString(switches);
|
||||
if (switchesSys.IsEmpty())
|
||||
if (!switches.IsEmpty())
|
||||
executeParameters += switches;
|
||||
|
||||
CSysString parametersSys = GetSystemString(executeParameters);
|
||||
if (parametersSys.IsEmpty())
|
||||
execInfo.lpParameters = NULL;
|
||||
else
|
||||
execInfo.lpParameters = switchesSys;
|
||||
execInfo.lpParameters = parametersSys;
|
||||
|
||||
execInfo.lpDirectory = NULL;
|
||||
execInfo.nShow = SW_SHOWNORMAL;
|
||||
@@ -264,7 +270,8 @@ int APIENTRY WinMain(
|
||||
result = (UINT32)execInfo.hInstApp;
|
||||
if(result <= 32)
|
||||
{
|
||||
MyMessageBox(L"Can not open file");
|
||||
if (!assumeYes)
|
||||
MyMessageBox(L"Can not open file");
|
||||
return 1;
|
||||
}
|
||||
hProcess = execInfo.hProcess;
|
||||
@@ -272,6 +279,25 @@ int APIENTRY WinMain(
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (appLaunched.IsEmpty())
|
||||
{
|
||||
appLaunched = L"setup.exe";
|
||||
if (!NFile::NFind::DoesFileExist(GetSystemString(appLaunched)))
|
||||
{
|
||||
if (!assumeYes)
|
||||
MyMessageBox(L"Can not find setup.exe");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
UString s2 = tempDirPath;
|
||||
NFile::NName::NormalizeDirPathPrefix(s2);
|
||||
appLaunched.Replace(L"%%T\\", s2);
|
||||
}
|
||||
|
||||
appLaunched.Replace(L"%%T", tempDirPath);
|
||||
|
||||
if (!switches.IsEmpty())
|
||||
{
|
||||
appLaunched += L' ';
|
||||
@@ -288,14 +314,15 @@ int APIENTRY WinMain(
|
||||
|
||||
PROCESS_INFORMATION processInformation;
|
||||
|
||||
CSysString appLaunchedSys = CSysString(TEXT(".\\")) + GetSystemString(appLaunched);
|
||||
CSysString appLaunchedSys = GetSystemString(dirPrefix + appLaunched);
|
||||
|
||||
BOOL createResult = CreateProcess(NULL, (LPTSTR)(LPCTSTR)appLaunchedSys,
|
||||
NULL, NULL, FALSE, 0, NULL, NULL /*tempDir.GetPath() */,
|
||||
&startupInfo, &processInformation);
|
||||
if (createResult == 0)
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
if (!assumeYes)
|
||||
ShowLastErrorMessage();
|
||||
return 1;
|
||||
}
|
||||
::CloseHandle(processInformation.hThread);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user