mirror of
https://github.com/Xevion/easy7zip.git
synced 2026-01-31 12:24:08 -06:00
4.46 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
a145bfc7cf
commit
c574fc0f4b
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
|
||||
#include "../../Common/MethodID.h"
|
||||
#include "../../Common/MethodId.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
@@ -157,7 +157,7 @@ HRESULT CDecoder::Decode(
|
||||
_mixerCoderCommon = _mixerCoderSTSpec;
|
||||
#endif
|
||||
}
|
||||
_mixerCoderCommon->SetBindInfo(bindInfo);
|
||||
RINOK(_mixerCoderCommon->SetBindInfo(bindInfo));
|
||||
|
||||
for (i = 0; i < numCoders; i++)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ HRESULT CEncoder::CreateMixerCoder(
|
||||
{
|
||||
_mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT;
|
||||
_mixerCoder = _mixerCoderSpec;
|
||||
_mixerCoderSpec->SetBindInfo(_bindInfo);
|
||||
RINOK(_mixerCoderSpec->SetBindInfo(_bindInfo));
|
||||
for (int i = 0; i < _options.Methods.Size(); i++)
|
||||
{
|
||||
const CMethodFull &methodFull = _options.Methods[i];
|
||||
|
||||
@@ -143,10 +143,12 @@ static inline UString GetHex2(Byte value)
|
||||
|
||||
static const UInt64 k_AES = 0x06F10701;
|
||||
|
||||
#ifndef _SFX
|
||||
static inline UInt32 GetUInt32FromMemLE(const Byte *p)
|
||||
{
|
||||
return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CHandler::IsEncrypted(UInt32 index2) const
|
||||
{
|
||||
@@ -393,11 +395,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
|
||||
static const wchar_t *kExt = L"7z";
|
||||
static const wchar_t *kAfterPart = L".7z";
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
|
||||
class CVolumeName
|
||||
{
|
||||
bool _first;
|
||||
|
||||
@@ -85,8 +85,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
#ifdef _7Z_VOL
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
|
||||
#endif
|
||||
|
||||
@@ -54,6 +54,9 @@ static const UInt32 kPpmdOrderX5 = 6;
|
||||
static const UInt32 kPpmdOrderX7 = 16;
|
||||
static const UInt32 kPpmdOrderX9 = 32;
|
||||
|
||||
static const UInt32 kDeflateAlgoX1 = 0;
|
||||
static const UInt32 kDeflateAlgoX5 = 1;
|
||||
|
||||
static const UInt32 kDeflateFastBytesX1 = 32;
|
||||
static const UInt32 kDeflateFastBytesX7 = 64;
|
||||
static const UInt32 kDeflateFastBytesX9 = 128;
|
||||
@@ -323,7 +326,11 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
(level >= 9 ? kDeflatePassesX9 :
|
||||
(level >= 7 ? kDeflatePassesX7 :
|
||||
kDeflatePassesX1));
|
||||
UInt32 algo =
|
||||
(level >= 5 ? kDeflateAlgoX5 :
|
||||
kDeflateAlgoX1);
|
||||
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algo);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
|
||||
}
|
||||
|
||||
@@ -1238,7 +1238,7 @@ HRESULT CInArchive::ReadDatabase(
|
||||
UInt64 nextHeaderSize;
|
||||
UInt32 nextHeaderCRC;
|
||||
UInt32 crc = CRC_INIT_VAL;
|
||||
UInt32 temp;
|
||||
UInt32 temp = 0;
|
||||
RINOK(SafeReadDirectUInt32(crcFromArchive, temp));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderOffset, crc));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderSize, crc));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "../../../Common/Buffer.h"
|
||||
#include "../../../Common/String.h"
|
||||
#include "../../Common/MethodID.h"
|
||||
#include "../../Common/MethodId.h"
|
||||
#include "7zHeader.h"
|
||||
|
||||
namespace NArchive {
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
enum // PropID
|
||||
enum
|
||||
{
|
||||
kpidPackedSize0 = kpidUserDefined,
|
||||
kpidPackedSize1,
|
||||
kpidPackedSize2,
|
||||
kpidPackedSize3,
|
||||
kpidPackedSize4,
|
||||
kpidPackedSize4
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -350,7 +350,6 @@ static bool IsExeFile(const UString &ext)
|
||||
return false;
|
||||
}
|
||||
|
||||
static const UInt64 k_Copy = 0x0;
|
||||
static const UInt64 k_LZMA = 0x030101;
|
||||
static const UInt64 k_BCJ = 0x03030103;
|
||||
static const UInt64 k_BCJ2 = 0x0303011B;
|
||||
@@ -843,6 +842,8 @@ static HRESULT Update2(
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
|
||||
static const UInt64 k_Copy = 0x0;
|
||||
|
||||
static HRESULT WriteVolumeHeader(COutArchive &archive, CFileItem &file, const CUpdateOptions &options)
|
||||
{
|
||||
CCoderInfo coder;
|
||||
|
||||
@@ -35,7 +35,7 @@ struct CUpdateItem
|
||||
bool IsLastAccessTimeDefined;
|
||||
bool AttributesAreDefined;
|
||||
|
||||
const bool HasStream() const
|
||||
bool HasStream() const
|
||||
{ return !IsDirectory && !IsAnti && Size != 0; }
|
||||
CUpdateItem():
|
||||
IsAnti(false),
|
||||
|
||||
@@ -15,7 +15,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *inStream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace NFileHeader
|
||||
kCompressed1c = 3,
|
||||
kCompressed2 = 4,
|
||||
kNoDataNoCRC = 8,
|
||||
kNoData = 9,
|
||||
kNoData = 9
|
||||
};
|
||||
}
|
||||
namespace NFileType
|
||||
@@ -62,7 +62,7 @@ namespace NFileHeader
|
||||
k7BitText = 1,
|
||||
kDirectory = 3,
|
||||
kVolumeLablel = 4,
|
||||
kChapterLabel = 5,
|
||||
kChapterLabel = 5
|
||||
};
|
||||
}
|
||||
namespace NFlags
|
||||
|
||||
@@ -46,8 +46,7 @@ class CHandler:
|
||||
}
|
||||
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
|
||||
@@ -54,8 +54,6 @@ STATPROPSTG kProperties[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
static const int kNumProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
|
||||
static const wchar_t *kMethods[] =
|
||||
{
|
||||
L"None",
|
||||
|
||||
@@ -15,7 +15,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
{
|
||||
kUnexpectedEndOfArchive = 0,
|
||||
kIncorrectArchive,
|
||||
kUnsupported,
|
||||
kUnsupported
|
||||
} Cause;
|
||||
CInArchiveException(CCauseType cause) : Cause(cause) {}
|
||||
};
|
||||
|
||||
@@ -55,8 +55,6 @@ STATPROPSTG kProperties[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
static const int kNumProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
|
||||
STDMETHODIMP CHandler::GetArchiveProperty(PROPID /* propID */, PROPVARIANT *value)
|
||||
{
|
||||
value->vt = VT_EMPTY;
|
||||
|
||||
@@ -15,7 +15,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -158,7 +158,7 @@ struct CCoderInfo
|
||||
class CCoderMixer2
|
||||
{
|
||||
public:
|
||||
virtual void SetBindInfo(const CBindInfo &bindInfo) = 0;
|
||||
virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) = 0;
|
||||
virtual void ReInit() = 0;
|
||||
virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0;
|
||||
};
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace NCoderMixer2 {
|
||||
|
||||
CThreadCoderInfo::CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams):
|
||||
ExitEvent(NULL),
|
||||
CompressEvent(NULL),
|
||||
CompressionCompletedEvent(NULL),
|
||||
CCoderInfo(numInStreams, numOutStreams)
|
||||
{
|
||||
InStreams.Reserve(NumInStreams);
|
||||
@@ -22,20 +20,6 @@ CThreadCoderInfo::CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams):
|
||||
OutStreamPointers.Reserve(NumOutStreams);
|
||||
}
|
||||
|
||||
void CThreadCoderInfo::CreateEvents()
|
||||
{
|
||||
CompressEvent = new CAutoResetEvent(false);
|
||||
CompressionCompletedEvent = new CAutoResetEvent(false);
|
||||
}
|
||||
|
||||
CThreadCoderInfo::~CThreadCoderInfo()
|
||||
{
|
||||
if (CompressEvent != NULL)
|
||||
delete CompressEvent;
|
||||
if (CompressionCompletedEvent != NULL)
|
||||
delete CompressionCompletedEvent;
|
||||
}
|
||||
|
||||
class CCoderInfoFlusher2
|
||||
{
|
||||
CThreadCoderInfo *m_CoderInfo;
|
||||
@@ -48,13 +32,13 @@ public:
|
||||
m_CoderInfo->InStreams[i].Release();
|
||||
for (i = 0; i < m_CoderInfo->OutStreams.Size(); i++)
|
||||
m_CoderInfo->OutStreams[i].Release();
|
||||
m_CoderInfo->CompressionCompletedEvent->Set();
|
||||
m_CoderInfo->CompressionCompletedEvent.Set();
|
||||
}
|
||||
};
|
||||
|
||||
bool CThreadCoderInfo::WaitAndCode()
|
||||
{
|
||||
HANDLE events[2] = { ExitEvent, *CompressEvent };
|
||||
HANDLE events[2] = { ExitEvent, CompressEvent };
|
||||
DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
|
||||
if (waitResult == WAIT_OBJECT_0 + 0)
|
||||
return false;
|
||||
@@ -123,7 +107,7 @@ void CThreadCoderInfo::SetCoderInfo(const UInt64 **inSizes,
|
||||
SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
|
||||
}
|
||||
|
||||
static DWORD WINAPI CoderThread(void *threadCoderInfo)
|
||||
static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@@ -135,7 +119,7 @@ static DWORD WINAPI CoderThread(void *threadCoderInfo)
|
||||
//////////////////////////////////////
|
||||
// CCoderMixer2MT
|
||||
|
||||
static DWORD WINAPI MainCoderThread(void *threadCoderInfo)
|
||||
static THREAD_FUNC_DECL MainCoderThread(void *threadCoderInfo)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@@ -146,7 +130,9 @@ static DWORD WINAPI MainCoderThread(void *threadCoderInfo)
|
||||
|
||||
CCoderMixer2MT::CCoderMixer2MT()
|
||||
{
|
||||
if (!_mainThread.Create(MainCoderThread, this))
|
||||
if (CreateEvents() != S_OK)
|
||||
throw 271824;
|
||||
if (_mainThread.Create(MainCoderThread, this) != S_OK)
|
||||
throw 271825;
|
||||
}
|
||||
|
||||
@@ -161,15 +147,16 @@ CCoderMixer2MT::~CCoderMixer2MT()
|
||||
}
|
||||
}
|
||||
|
||||
void CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
|
||||
HRESULT CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
|
||||
{
|
||||
_bindInfo = bindInfo;
|
||||
_streamBinders.Clear();
|
||||
for(int i = 0; i < _bindInfo.BindPairs.Size(); i++)
|
||||
{
|
||||
_streamBinders.Add(CStreamBinder());
|
||||
_streamBinders.Back().CreateEvents();
|
||||
RINOK(_streamBinders.Back().CreateEvents());
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CCoderMixer2MT::AddCoderCommon()
|
||||
@@ -180,13 +167,13 @@ void CCoderMixer2MT::AddCoderCommon()
|
||||
CThreadCoderInfo threadCoderInfo(CoderStreamsInfo.NumInStreams,
|
||||
CoderStreamsInfo.NumOutStreams);
|
||||
_coderInfoVector.Add(threadCoderInfo);
|
||||
_coderInfoVector.Back().CreateEvents();
|
||||
_coderInfoVector.Back().ExitEvent = _exitEvent;
|
||||
_compressingCompletedEvents.Add(*_coderInfoVector.Back().CompressionCompletedEvent);
|
||||
CThreadCoderInfo *tci = &_coderInfoVector.Back();
|
||||
tci->CreateEvents();
|
||||
tci->ExitEvent = _exitEvent;
|
||||
|
||||
NWindows::CThread newThread;
|
||||
_threads.Add(newThread);
|
||||
if (!_threads.Back().Create(CoderThread, &_coderInfoVector.Back()))
|
||||
if (_threads.Back().Create(CoderThread, tci) != S_OK)
|
||||
throw 271824;
|
||||
}
|
||||
|
||||
@@ -282,13 +269,13 @@ bool CCoderMixer2MT::MyCode()
|
||||
if (waitResult == WAIT_OBJECT_0 + 0)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < _coderInfoVector.Size(); i++)
|
||||
_coderInfoVector[i].CompressEvent->Set();
|
||||
/* DWORD result = */ ::WaitForMultipleObjects(_compressingCompletedEvents.Size(),
|
||||
&_compressingCompletedEvents.Front(), TRUE, INFINITE);
|
||||
|
||||
_compressingFinishedEvent.Set();
|
||||
int i;
|
||||
for(i = 0; i < _coderInfoVector.Size(); i++)
|
||||
_coderInfoVector[i].CompressEvent.Set();
|
||||
for (i = 0; i < _coderInfoVector.Size(); i++)
|
||||
_coderInfoVector[i].CompressionCompletedEvent.Lock();
|
||||
|
||||
_compressingFinishedEvent.Set();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -311,6 +298,7 @@ STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams,
|
||||
|
||||
CCrossThreadProgress *progressSpec = new CCrossThreadProgress;
|
||||
CMyComPtr<ICompressProgressInfo> crossProgress = progressSpec;
|
||||
RINOK(progressSpec->Create());
|
||||
progressSpec->Init();
|
||||
_coderInfoVector[_progressCoderIndex].Progress = crossProgress;
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace NCoderMixer2 {
|
||||
|
||||
struct CThreadCoderInfo: public CCoderInfo
|
||||
{
|
||||
NWindows::NSynchronization::CAutoResetEvent *CompressEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent CompressEvent;
|
||||
HANDLE ExitEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent *CompressionCompletedEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent CompressionCompletedEvent;
|
||||
|
||||
CObjectVector< CMyComPtr<ISequentialInStream> > InStreams;
|
||||
CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams;
|
||||
@@ -35,9 +35,12 @@ struct CThreadCoderInfo: public CCoderInfo
|
||||
CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams);
|
||||
void SetCoderInfo(const UInt64 **inSizes,
|
||||
const UInt64 **outSizes, ICompressProgressInfo *progress);
|
||||
~CThreadCoderInfo();
|
||||
bool WaitAndCode();
|
||||
void CreateEvents();
|
||||
HRes CreateEvents()
|
||||
{
|
||||
RINOK(CompressEvent.CreateIfNotCreated());
|
||||
return CompressionCompletedEvent.CreateIfNotCreated();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -105,14 +108,20 @@ private:
|
||||
NWindows::CThread _mainThread;
|
||||
|
||||
NWindows::NSynchronization::CAutoResetEvent _startCompressingEvent;
|
||||
CRecordVector<HANDLE> _compressingCompletedEvents;
|
||||
NWindows::NSynchronization::CAutoResetEvent _compressingFinishedEvent;
|
||||
|
||||
NWindows::NSynchronization::CManualResetEvent _exitEvent;
|
||||
UInt32 _progressCoderIndex;
|
||||
|
||||
HRes CreateEvents()
|
||||
{
|
||||
RINOK(_startCompressingEvent.CreateIfNotCreated());
|
||||
RINOK(_compressingFinishedEvent.CreateIfNotCreated());
|
||||
return _exitEvent.CreateIfNotCreated();
|
||||
}
|
||||
|
||||
public:
|
||||
void SetBindInfo(const CBindInfo &bindInfo);
|
||||
HRESULT SetBindInfo(const CBindInfo &bindInfo);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,9 +10,10 @@ CCoderMixer2ST::CCoderMixer2ST() {}
|
||||
|
||||
CCoderMixer2ST::~CCoderMixer2ST(){ }
|
||||
|
||||
void CCoderMixer2ST::SetBindInfo(const CBindInfo &bindInfo)
|
||||
HRESULT CCoderMixer2ST::SetBindInfo(const CBindInfo &bindInfo)
|
||||
{
|
||||
_bindInfo = bindInfo;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CCoderMixer2ST::AddCoderCommon(bool isMain)
|
||||
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
CObjectVector<CSTCoderInfo> _coders;
|
||||
int _mainCoderIndex;
|
||||
public:
|
||||
void SetBindInfo(const CBindInfo &bindInfo);
|
||||
HRESULT SetBindInfo(const CBindInfo &bindInfo);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,12 @@ public:
|
||||
HRESULT Result;
|
||||
NWindows::NSynchronization::CAutoResetEvent ProgressEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent WaitEvent;
|
||||
|
||||
HRes Create()
|
||||
{
|
||||
RINOK(ProgressEvent.CreateIfNotCreated());
|
||||
return WaitEvent.CreateIfNotCreated();
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
ProgressEvent.Reset();
|
||||
|
||||
@@ -16,7 +16,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -16,7 +16,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -19,6 +19,7 @@ extern "C"
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
#ifdef _WIN32
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
@@ -29,6 +30,7 @@ static bool IsItWindowsNT()
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
@@ -37,8 +39,10 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
#ifdef _WIN32
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
#endif
|
||||
#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
|
||||
SetLargePageSize();
|
||||
#endif
|
||||
|
||||
@@ -23,8 +23,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
@@ -79,7 +78,8 @@ private:
|
||||
void InitMethodProperties()
|
||||
{
|
||||
m_Method.NumMatchFinderCyclesDefined = false;
|
||||
m_Level = m_Method.NumPasses = m_Method.NumFastBytes = m_Method.NumMatchFinderCycles = 0xFFFFFFFF;
|
||||
m_Level = m_Method.NumPasses = m_Method.NumFastBytes =
|
||||
m_Method.NumMatchFinderCycles = m_Method.Algo = 0xFFFFFFFF;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ using namespace NTime;
|
||||
namespace NArchive {
|
||||
namespace NGZip {
|
||||
|
||||
static const UInt32 kAlgoX1 = 0;
|
||||
static const UInt32 kAlgoX5 = 1;
|
||||
|
||||
static const UInt32 kNumPassesX1 = 1;
|
||||
static const UInt32 kNumPassesX7 = 3;
|
||||
static const UInt32 kNumPassesX9 = 10;
|
||||
@@ -137,6 +140,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
m_Method.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
|
||||
(level >= 7 ? kNumFastBytesX7 :
|
||||
kNumFastBytesX1));
|
||||
if (m_Method.Algo == 0xFFFFFFFF)
|
||||
m_Method.Algo =
|
||||
(level >= 5 ? kAlgoX5 :
|
||||
kAlgoX1);
|
||||
|
||||
return UpdateArchive(
|
||||
EXTERNAL_CODECS_VARS
|
||||
@@ -193,6 +200,12 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
m_Method.NumMatchFinderCycles = num;
|
||||
m_Method.NumMatchFinderCyclesDefined = true;
|
||||
}
|
||||
else if (name.Left(1) == L"A")
|
||||
{
|
||||
UInt32 num = kAlgoX5;
|
||||
RINOK(ParsePropValue(name.Mid(1), prop, num));
|
||||
m_Method.Algo = num;
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ HRESULT CInArchive::ReadBytes(ISequentialInStream *inStream, void *data, UInt32
|
||||
|
||||
HRESULT CInArchive::ReadByte(ISequentialInStream *inStream, Byte &value, UInt32 &crc)
|
||||
{
|
||||
HRESULT res = ReadBytes(inStream, &value, 1);
|
||||
RINOK(ReadBytes(inStream, &value, 1));
|
||||
crc = CRC_UPDATE_BYTE(crc, value);
|
||||
return res;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadUInt16(ISequentialInStream *inStream, UInt16 &value, UInt32 &crc)
|
||||
|
||||
@@ -83,12 +83,14 @@ HRESULT UpdateArchive(
|
||||
|
||||
NWindows::NCOM::CPropVariant properties[] =
|
||||
{
|
||||
compressionMethod.Algo,
|
||||
compressionMethod.NumPasses,
|
||||
compressionMethod.NumFastBytes,
|
||||
compressionMethod.NumMatchFinderCycles
|
||||
};
|
||||
PROPID propIDs[] =
|
||||
{
|
||||
NCoderPropID::kAlgorithm,
|
||||
NCoderPropID::kNumPasses,
|
||||
NCoderPropID::kNumFastBytes,
|
||||
NCoderPropID::kMatchFinderCycles
|
||||
|
||||
@@ -17,6 +17,7 @@ struct CCompressionMethodMode
|
||||
{
|
||||
UInt32 NumPasses;
|
||||
UInt32 NumFastBytes;
|
||||
UInt32 Algo;
|
||||
bool NumMatchFinderCyclesDefined;
|
||||
UInt32 NumMatchFinderCycles;
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace NArchive
|
||||
{
|
||||
kExtract = 0,
|
||||
kTest,
|
||||
kSkip,
|
||||
kSkip
|
||||
};
|
||||
}
|
||||
namespace NOperationResult
|
||||
@@ -58,7 +58,7 @@ namespace NArchive
|
||||
kOK = 0,
|
||||
kUnSupportedMethod,
|
||||
kDataError,
|
||||
kCRCError,
|
||||
kCRCError
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace NArchive
|
||||
enum
|
||||
{
|
||||
kOK = 0,
|
||||
kError,
|
||||
kError
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Tar/Handler.h
|
||||
// Iso/Handler.h
|
||||
|
||||
#ifndef __ISO_HANDLER_H
|
||||
#define __ISO_HANDLER_H
|
||||
|
||||
@@ -15,7 +15,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *inStream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -27,8 +27,7 @@ class CHandler:
|
||||
bool GetCompressedSize(int index, UInt32 &size);
|
||||
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
@@ -23,7 +23,9 @@ public:
|
||||
SignatureInitializer() { kSignature[0]--; };
|
||||
} g_SignatureInitializer;
|
||||
|
||||
#ifdef NSIS_SCRIPT
|
||||
static const char *kCrLf = "\x0D\x0A";
|
||||
#endif
|
||||
|
||||
UInt32 GetUInt32FromMemLE(const Byte *p)
|
||||
{
|
||||
@@ -245,6 +247,7 @@ enum
|
||||
EW_LOCKWINDOW
|
||||
};
|
||||
|
||||
#ifdef NSIS_SCRIPT
|
||||
static CCommandPair kCommandPairs[] =
|
||||
{
|
||||
{ 0, "Invalid" },
|
||||
@@ -324,6 +327,7 @@ static CCommandPair kCommandPairs[] =
|
||||
{ 6, "LockWindow" }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static const char *kShellStrings[] =
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "../../IPassword.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../Common/MethodID.h"
|
||||
#include "../../Common/MethodId.h"
|
||||
#include "../../Common/FilterCoder.h"
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
#include "../../Crypto/Rar20/Rar20Cipher.h"
|
||||
|
||||
@@ -18,7 +18,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
@@ -17,8 +17,6 @@ extern "C"
|
||||
namespace NArchive {
|
||||
namespace NRar {
|
||||
|
||||
static const char kEndOfString = '\0';
|
||||
|
||||
void CInArchive::ThrowExceptionWithCode(
|
||||
CInArchiveException::CCauseType cause)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
kUnexpectedEndOfArchive = 0,
|
||||
kArchiveHeaderCRCError,
|
||||
kFileHeaderCRCError,
|
||||
kIncorrectArchive,
|
||||
kIncorrectArchive
|
||||
}
|
||||
Cause;
|
||||
CInArchiveException(CCauseType cause) : Cause(cause) {}
|
||||
|
||||
@@ -17,7 +17,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(IInArchiveGetStream)
|
||||
MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -14,7 +14,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -166,12 +166,14 @@ HRESULT CAddCommon::Compress(
|
||||
{
|
||||
NWindows::NCOM::CPropVariant properties[] =
|
||||
{
|
||||
_options.Algo,
|
||||
_options.NumPasses,
|
||||
_options.NumFastBytes,
|
||||
_options.NumMatchFinderCycles
|
||||
};
|
||||
PROPID propIDs[] =
|
||||
{
|
||||
NCoderPropID::kAlgorithm,
|
||||
NCoderPropID::kNumPasses,
|
||||
NCoderPropID::kNumFastBytes,
|
||||
NCoderPropID::kMatchFinderCycles
|
||||
|
||||
@@ -13,6 +13,7 @@ struct CCompressionMethodMode
|
||||
{
|
||||
CRecordVector<Byte> MethodSequence;
|
||||
// bool MaximizeRatio;
|
||||
UInt32 Algo;
|
||||
UInt32 NumPasses;
|
||||
UInt32 NumFastBytes;
|
||||
bool NumMatchFinderCyclesDefined;
|
||||
|
||||
@@ -37,7 +37,7 @@ using namespace NTime;
|
||||
namespace NArchive {
|
||||
namespace NZip {
|
||||
|
||||
static const CMethodId kMethodId_Store = 0;
|
||||
// static const CMethodId kMethodId_Store = 0;
|
||||
static const CMethodId kMethodId_ZipBase = 0x040100;
|
||||
static const CMethodId kMethodId_BZip2 = 0x040202;
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
@@ -73,6 +72,7 @@ private:
|
||||
int m_Level;
|
||||
int m_MainMethod;
|
||||
UInt32 m_DicSize;
|
||||
UInt32 m_Algo;
|
||||
UInt32 m_NumPasses;
|
||||
UInt32 m_NumFastBytes;
|
||||
UInt32 m_NumMatchFinderCycles;
|
||||
@@ -91,6 +91,7 @@ private:
|
||||
{
|
||||
m_Level = -1;
|
||||
m_MainMethod = -1;
|
||||
m_Algo =
|
||||
m_DicSize =
|
||||
m_NumPasses =
|
||||
m_NumFastBytes =
|
||||
|
||||
@@ -24,6 +24,9 @@ using namespace NTime;
|
||||
namespace NArchive {
|
||||
namespace NZip {
|
||||
|
||||
static const UInt32 kDeflateAlgoX1 = 0;
|
||||
static const UInt32 kDeflateAlgoX5 = 1;
|
||||
|
||||
static const UInt32 kDeflateNumPassesX1 = 1;
|
||||
static const UInt32 kDeflateNumPassesX7 = 3;
|
||||
static const UInt32 kDeflateNumPassesX9 = 10;
|
||||
@@ -238,6 +241,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
options.NumFastBytes = m_NumFastBytes;
|
||||
options.NumMatchFinderCycles = m_NumMatchFinderCycles;
|
||||
options.NumMatchFinderCyclesDefined = m_NumMatchFinderCyclesDefined;
|
||||
options.Algo = m_Algo;
|
||||
#ifdef COMPRESS_MT
|
||||
options.NumThreads = _numThreads;
|
||||
#endif
|
||||
@@ -251,6 +255,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
options.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
|
||||
(level >= 7 ? kNumFastBytesX7 :
|
||||
kNumFastBytesX1));
|
||||
if (options.Algo == 0xFFFFFFFF)
|
||||
options.Algo =
|
||||
(level >= 5 ? kDeflateAlgoX5 :
|
||||
kDeflateAlgoX1);
|
||||
}
|
||||
if (isBZip2)
|
||||
{
|
||||
@@ -386,6 +394,12 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads));
|
||||
#endif
|
||||
}
|
||||
else if (name.Left(1) == L"A")
|
||||
{
|
||||
UInt32 num = kDeflateAlgoX5;
|
||||
RINOK(ParsePropValue(name.Mid(1), prop, num));
|
||||
m_Algo = num;
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ bool CLocalItem::IsImplodeLiteralsOn() const
|
||||
return (Flags & NFileHeader::NFlags::kImplodeLiteralsOnMask) != 0;
|
||||
}
|
||||
|
||||
static const char *kUnknownAttributes = "Unknown file attributes";
|
||||
|
||||
bool CLocalItem::IsDirectory() const
|
||||
{
|
||||
return NItemName::HasTailSlash(Name, GetCodePage());
|
||||
|
||||
@@ -30,16 +30,6 @@ using namespace NSynchronization;
|
||||
namespace NArchive {
|
||||
namespace NZip {
|
||||
|
||||
class CCriticalSectionLock2
|
||||
{
|
||||
CCriticalSection *_object;
|
||||
void Unlock() { if (_object != 0) _object->Leave(); }
|
||||
public:
|
||||
CCriticalSectionLock2(): _object(0) {}
|
||||
void Set(CCriticalSection &object) { _object = &object; _object->Enter(); }
|
||||
~CCriticalSectionLock2() { Unlock(); }
|
||||
};
|
||||
|
||||
static const Byte kMadeByHostOS = NFileHeader::NHostOS::kFAT;
|
||||
static const Byte kExtractHostOS = NFileHeader::NHostOS::kFAT;
|
||||
|
||||
@@ -135,7 +125,7 @@ static void SetItemInfoFromCompressingResult(const CCompressingResult &compressi
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
|
||||
static DWORD WINAPI CoderThread(void *threadCoderInfo);
|
||||
static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo);
|
||||
|
||||
struct CThreadInfo
|
||||
{
|
||||
@@ -145,8 +135,8 @@ struct CThreadInfo
|
||||
#endif
|
||||
|
||||
NWindows::CThread Thread;
|
||||
CAutoResetEvent *CompressEvent;
|
||||
CAutoResetEvent *CompressionCompletedEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent CompressEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent CompressionCompletedEvent;
|
||||
bool ExitThread;
|
||||
|
||||
CMtCompressProgress *ProgressSpec;
|
||||
@@ -164,21 +154,18 @@ struct CThreadInfo
|
||||
UInt32 UpdateIndex;
|
||||
|
||||
CThreadInfo(const CCompressionMethodMode &options):
|
||||
CompressEvent(NULL),
|
||||
CompressionCompletedEvent(NULL),
|
||||
ExitThread(false),
|
||||
ProgressSpec(0),
|
||||
OutStreamSpec(0),
|
||||
Coder(options)
|
||||
{}
|
||||
|
||||
void CreateEvents()
|
||||
HRESULT CreateEvents()
|
||||
{
|
||||
CompressEvent = new CAutoResetEvent(false);
|
||||
CompressionCompletedEvent = new CAutoResetEvent(false);
|
||||
RINOK(CompressEvent.CreateIfNotCreated());
|
||||
return CompressionCompletedEvent.CreateIfNotCreated();
|
||||
}
|
||||
bool CreateThread() { return Thread.Create(CoderThread, this); }
|
||||
~CThreadInfo();
|
||||
HRes CreateThread() { return Thread.Create(CoderThread, this); }
|
||||
|
||||
void WaitAndCode();
|
||||
void StopWaitClose()
|
||||
@@ -186,27 +173,19 @@ struct CThreadInfo
|
||||
ExitThread = true;
|
||||
if (OutStreamSpec != 0)
|
||||
OutStreamSpec->StopWriting(E_ABORT);
|
||||
if (CompressEvent != NULL)
|
||||
CompressEvent->Set();
|
||||
if (CompressEvent.IsCreated())
|
||||
CompressEvent.Set();
|
||||
Thread.Wait();
|
||||
Thread.Close();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CThreadInfo::~CThreadInfo()
|
||||
{
|
||||
if (CompressEvent != NULL)
|
||||
delete CompressEvent;
|
||||
if (CompressionCompletedEvent != NULL)
|
||||
delete CompressionCompletedEvent;
|
||||
}
|
||||
|
||||
void CThreadInfo::WaitAndCode()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
CompressEvent->Lock();
|
||||
CompressEvent.Lock();
|
||||
if (ExitThread)
|
||||
return;
|
||||
Result = Coder.Compress(
|
||||
@@ -216,11 +195,11 @@ void CThreadInfo::WaitAndCode()
|
||||
InStream, OutStream, Progress, CompressingResult);
|
||||
if (Result == S_OK && Progress)
|
||||
Result = Progress->SetRatioInfo(&CompressingResult.UnpackSize, &CompressingResult.PackSize);
|
||||
CompressionCompletedEvent->Set();
|
||||
CompressionCompletedEvent.Set();
|
||||
}
|
||||
}
|
||||
|
||||
static DWORD WINAPI CoderThread(void *threadCoderInfo)
|
||||
static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo)
|
||||
{
|
||||
((CThreadInfo *)threadCoderInfo)->WaitAndCode();
|
||||
return 0;
|
||||
@@ -518,8 +497,7 @@ static HRESULT Update2(
|
||||
CRecordVector<int> threadIndices; // list threads in order of updateItems
|
||||
|
||||
{
|
||||
if (!memManager.AllocateSpaceAlways((size_t)numThreads * (kMemPerThread / kBlockSize)))
|
||||
return E_OUTOFMEMORY;
|
||||
RINOK(memManager.AllocateSpaceAlways((size_t)numThreads * (kMemPerThread / kBlockSize)));
|
||||
for(i = 0; i < updateItems.Size(); i++)
|
||||
refs.Refs.Add(CMemBlocks2());
|
||||
|
||||
@@ -534,15 +512,15 @@ static HRESULT Update2(
|
||||
threadInfo._codecsInfo = codecsInfo;
|
||||
threadInfo._externalCodecs = externalCodecs;
|
||||
#endif
|
||||
threadInfo.CreateEvents();
|
||||
RINOK(threadInfo.CreateEvents());
|
||||
threadInfo.OutStreamSpec = new COutMemStream(&memManager);
|
||||
RINOK(threadInfo.OutStreamSpec->CreateEvents());
|
||||
threadInfo.OutStream = threadInfo.OutStreamSpec;
|
||||
threadInfo.IsFree = true;
|
||||
threadInfo.ProgressSpec = new CMtCompressProgress();
|
||||
threadInfo.Progress = threadInfo.ProgressSpec;
|
||||
threadInfo.ProgressSpec->Init(&mtCompressProgressMixer, (int)i);
|
||||
if (!threadInfo.CreateThread())
|
||||
return ::GetLastError();
|
||||
RINOK(threadInfo.CreateThread());
|
||||
}
|
||||
}
|
||||
int mtItemIndex = 0;
|
||||
@@ -601,10 +579,10 @@ static HRESULT Update2(
|
||||
|
||||
threadInfo.OutStreamSpec->Init();
|
||||
threadInfo.ProgressSpec->Reinit();
|
||||
threadInfo.CompressEvent->Set();
|
||||
threadInfo.CompressEvent.Set();
|
||||
threadInfo.UpdateIndex = mtItemIndex - 1;
|
||||
|
||||
compressingCompletedEvents.Add(*threadInfo.CompressionCompletedEvent);
|
||||
compressingCompletedEvents.Add(threadInfo.CompressionCompletedEvent);
|
||||
threadIndices.Add(i);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user