Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Archive')
-rwxr-xr-xCPP/7zip/Archive/7z/7zCompressionMode.h2
-rwxr-xr-xCPP/7zip/Archive/7z/7zDecode.cpp2
-rwxr-xr-xCPP/7zip/Archive/7z/7zEncode.cpp2
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.cpp6
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.h3
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandlerOut.cpp7
-rwxr-xr-xCPP/7zip/Archive/7z/7zIn.cpp2
-rwxr-xr-xCPP/7zip/Archive/7z/7zItem.h2
-rwxr-xr-xCPP/7zip/Archive/7z/7zProperties.h4
-rwxr-xr-xCPP/7zip/Archive/7z/7zUpdate.cpp3
-rwxr-xr-xCPP/7zip/Archive/7z/7zUpdate.h2
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjHeader.h4
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2Handler.h3
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Cab/CabIn.h2
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2.h2
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2MT.cpp54
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2MT.h21
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2ST.cpp3
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2ST.h2
-rwxr-xr-xCPP/7zip/Archive/Common/CrossThreadProgress.h6
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Deb/DebHandler.h2
-rwxr-xr-xCPP/7zip/Archive/DllExports2.cpp4
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHandler.h6
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHandlerOut.cpp13
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipIn.cpp4
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipUpdate.cpp2
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipUpdate.h1
-rwxr-xr-xCPP/7zip/Archive/IArchive.h6
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisHandler.h3
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisIn.cpp4
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.cpp2
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.h2
-rwxr-xr-xCPP/7zip/Archive/Split/SplitHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Z/ZHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipAddCommon.cpp2
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipCompressionMode.h1
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.h5
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandlerOut.cpp14
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipItem.cpp2
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipUpdate.cpp58
52 files changed, 157 insertions, 134 deletions
diff --git a/CPP/7zip/Archive/7z/7zCompressionMode.h b/CPP/7zip/Archive/7z/7zCompressionMode.h
index 4c4527f2..65e573d1 100755
--- a/CPP/7zip/Archive/7z/7zCompressionMode.h
+++ b/CPP/7zip/Archive/7z/7zCompressionMode.h
@@ -7,7 +7,7 @@
#include "../../../Windows/PropVariant.h"
-#include "../../Common/MethodID.h"
+#include "../../Common/MethodId.h"
namespace NArchive {
namespace N7z {
diff --git a/CPP/7zip/Archive/7z/7zDecode.cpp b/CPP/7zip/Archive/7z/7zDecode.cpp
index bce9b009..19b08b78 100755
--- a/CPP/7zip/Archive/7z/7zDecode.cpp
+++ b/CPP/7zip/Archive/7z/7zDecode.cpp
@@ -157,7 +157,7 @@ HRESULT CDecoder::Decode(
_mixerCoderCommon = _mixerCoderSTSpec;
#endif
}
- _mixerCoderCommon->SetBindInfo(bindInfo);
+ RINOK(_mixerCoderCommon->SetBindInfo(bindInfo));
for (i = 0; i < numCoders; i++)
{
diff --git a/CPP/7zip/Archive/7z/7zEncode.cpp b/CPP/7zip/Archive/7z/7zEncode.cpp
index ef0b757b..ef74b9bf 100755
--- a/CPP/7zip/Archive/7z/7zEncode.cpp
+++ b/CPP/7zip/Archive/7z/7zEncode.cpp
@@ -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];
diff --git a/CPP/7zip/Archive/7z/7zHandler.cpp b/CPP/7zip/Archive/7z/7zHandler.cpp
index abccdce9..dc0a6505 100755
--- a/CPP/7zip/Archive/7z/7zHandler.cpp
+++ b/CPP/7zip/Archive/7z/7zHandler.cpp
@@ -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;
diff --git a/CPP/7zip/Archive/7z/7zHandler.h b/CPP/7zip/Archive/7z/7zHandler.h
index 26675b78..77e4d25c 100755
--- a/CPP/7zip/Archive/7z/7zHandler.h
+++ b/CPP/7zip/Archive/7z/7zHandler.h
@@ -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
diff --git a/CPP/7zip/Archive/7z/7zHandlerOut.cpp b/CPP/7zip/Archive/7z/7zHandlerOut.cpp
index 2508e518..80d63931 100755
--- a/CPP/7zip/Archive/7z/7zHandlerOut.cpp
+++ b/CPP/7zip/Archive/7z/7zHandlerOut.cpp
@@ -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);
}
diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp
index 6c709b89..d1ad9da8 100755
--- a/CPP/7zip/Archive/7z/7zIn.cpp
+++ b/CPP/7zip/Archive/7z/7zIn.cpp
@@ -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));
diff --git a/CPP/7zip/Archive/7z/7zItem.h b/CPP/7zip/Archive/7z/7zItem.h
index c4f9dc13..cad88dc1 100755
--- a/CPP/7zip/Archive/7z/7zItem.h
+++ b/CPP/7zip/Archive/7z/7zItem.h
@@ -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 {
diff --git a/CPP/7zip/Archive/7z/7zProperties.h b/CPP/7zip/Archive/7z/7zProperties.h
index a09839bb..4da85f04 100755
--- a/CPP/7zip/Archive/7z/7zProperties.h
+++ b/CPP/7zip/Archive/7z/7zProperties.h
@@ -8,13 +8,13 @@
namespace NArchive {
namespace N7z {
-enum // PropID
+enum
{
kpidPackedSize0 = kpidUserDefined,
kpidPackedSize1,
kpidPackedSize2,
kpidPackedSize3,
- kpidPackedSize4,
+ kpidPackedSize4
};
}}
diff --git a/CPP/7zip/Archive/7z/7zUpdate.cpp b/CPP/7zip/Archive/7z/7zUpdate.cpp
index 30b97632..2b197adb 100755
--- a/CPP/7zip/Archive/7z/7zUpdate.cpp
+++ b/CPP/7zip/Archive/7z/7zUpdate.cpp
@@ -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;
diff --git a/CPP/7zip/Archive/7z/7zUpdate.h b/CPP/7zip/Archive/7z/7zUpdate.h
index e19d7a2d..ac1b5b65 100755
--- a/CPP/7zip/Archive/7z/7zUpdate.h
+++ b/CPP/7zip/Archive/7z/7zUpdate.h
@@ -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),
diff --git a/CPP/7zip/Archive/Arj/ArjHandler.h b/CPP/7zip/Archive/Arj/ArjHandler.h
index a1e69ba6..58e67401 100755
--- a/CPP/7zip/Archive/Arj/ArjHandler.h
+++ b/CPP/7zip/Archive/Arj/ArjHandler.h
@@ -15,7 +15,7 @@ class CHandler:
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP
+ MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *inStream,
const UInt64 *maxCheckStartPosition,
diff --git a/CPP/7zip/Archive/Arj/ArjHeader.h b/CPP/7zip/Archive/Arj/ArjHeader.h
index 58ee8c27..7aca1b98 100755
--- a/CPP/7zip/Archive/Arj/ArjHeader.h
+++ b/CPP/7zip/Archive/Arj/ArjHeader.h
@@ -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
diff --git a/CPP/7zip/Archive/BZip2/BZip2Handler.h b/CPP/7zip/Archive/BZip2/BZip2Handler.h
index c7049d2f..96854eca 100755
--- a/CPP/7zip/Archive/BZip2/BZip2Handler.h
+++ b/CPP/7zip/Archive/BZip2/BZip2Handler.h
@@ -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
diff --git a/CPP/7zip/Archive/Cab/CabHandler.cpp b/CPP/7zip/Archive/Cab/CabHandler.cpp
index f23484f7..1c0e2feb 100755
--- a/CPP/7zip/Archive/Cab/CabHandler.cpp
+++ b/CPP/7zip/Archive/Cab/CabHandler.cpp
@@ -54,8 +54,6 @@ STATPROPSTG kProperties[] =
#endif
};
-static const int kNumProperties = sizeof(kProperties) / sizeof(kProperties[0]);
-
static const wchar_t *kMethods[] =
{
L"None",
diff --git a/CPP/7zip/Archive/Cab/CabHandler.h b/CPP/7zip/Archive/Cab/CabHandler.h
index 245586b6..f5b6e39c 100755
--- a/CPP/7zip/Archive/Cab/CabHandler.h
+++ b/CPP/7zip/Archive/Cab/CabHandler.h
@@ -15,7 +15,7 @@ class CHandler:
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP
+ MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
diff --git a/CPP/7zip/Archive/Cab/CabIn.h b/CPP/7zip/Archive/Cab/CabIn.h
index aa3008f1..ebeead87 100755
--- a/CPP/7zip/Archive/Cab/CabIn.h
+++ b/CPP/7zip/Archive/Cab/CabIn.h
@@ -18,7 +18,7 @@ public:
{
kUnexpectedEndOfArchive = 0,
kIncorrectArchive,
- kUnsupported,
+ kUnsupported
} Cause;
CInArchiveException(CCauseType cause) : Cause(cause) {}
};
diff --git a/CPP/7zip/Archive/Chm/ChmHandler.cpp b/CPP/7zip/Archive/Chm/ChmHandler.cpp
index 6b37c73e..5de871da 100755
--- a/CPP/7zip/Archive/Chm/ChmHandler.cpp
+++ b/CPP/7zip/Archive/Chm/ChmHandler.cpp
@@ -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;
diff --git a/CPP/7zip/Archive/Chm/ChmHandler.h b/CPP/7zip/Archive/Chm/ChmHandler.h
index dd0692ba..82eeb290 100755
--- a/CPP/7zip/Archive/Chm/ChmHandler.h
+++ b/CPP/7zip/Archive/Chm/ChmHandler.h
@@ -15,7 +15,7 @@ class CHandler:
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP
+ MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
diff --git a/CPP/7zip/Archive/Common/CoderMixer2.h b/CPP/7zip/Archive/Common/CoderMixer2.h
index 78a3f280..597a7b60 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2.h
+++ b/CPP/7zip/Archive/Common/CoderMixer2.h
@@ -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;
};
diff --git a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp
index c3b37f2d..8a37a10d 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp
+++ b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp
@@ -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;
diff --git a/CPP/7zip/Archive/Common/CoderMixer2MT.h b/CPP/7zip/Archive/Common/CoderMixer2MT.h
index 78d752de..67c0c8a5 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2MT.h
+++ b/CPP/7zip/Archive/Common/CoderMixer2MT.h
@@ -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);
};
diff --git a/CPP/7zip/Archive/Common/CoderMixer2ST.cpp b/CPP/7zip/Archive/Common/CoderMixer2ST.cpp
index c01b776d..6bcab0dd 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2ST.cpp
+++ b/CPP/7zip/Archive/Common/CoderMixer2ST.cpp
@@ -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)
diff --git a/CPP/7zip/Archive/Common/CoderMixer2ST.h b/CPP/7zip/Archive/Common/CoderMixer2ST.h
index 3144918b..ea5a53e3 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2ST.h
+++ b/CPP/7zip/Archive/Common/CoderMixer2ST.h
@@ -79,7 +79,7 @@ private:
CObjectVector<CSTCoderInfo> _coders;
int _mainCoderIndex;
public:
- void SetBindInfo(const CBindInfo &bindInfo);
+ HRESULT SetBindInfo(const CBindInfo &bindInfo);
};
diff --git a/CPP/7zip/Archive/Common/CrossThreadProgress.h b/CPP/7zip/Archive/Common/CrossThreadProgress.h
index 5dd339dc..b5422a31 100755
--- a/CPP/7zip/Archive/Common/CrossThreadProgress.h
+++ b/CPP/7zip/Archive/Common/CrossThreadProgress.h
@@ -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();
diff --git a/CPP/7zip/Archive/Cpio/CpioHandler.h b/CPP/7zip/Archive/Cpio/CpioHandler.h
index 39702541..eed1a06a 100755
--- a/CPP/7zip/Archive/Cpio/CpioHandler.h
+++ b/CPP/7zip/Archive/Cpio/CpioHandler.h
@@ -16,7 +16,7 @@ class CHandler:
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP
+ MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
diff --git a/CPP/7zip/Archive/Deb/DebHandler.h b/CPP/7zip/Archive/Deb/DebHandler.h
index 47de0224..4419dcdd 100755
--- a/CPP/7zip/Archive/Deb/DebHandler.h
+++ b/CPP/7zip/Archive/Deb/DebHandler.h
@@ -16,7 +16,7 @@ class CHandler:
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP
+ MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
diff --git a/CPP/7zip/Archive/DllExports2.cpp b/CPP/7zip/Archive/DllExports2.cpp
index cdf00346..216afdb1 100755
--- a/CPP/7zip/Archive/DllExports2.cpp
+++ b/CPP/7zip/Archive/DllExports2.cpp
@@ -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
diff --git a/CPP/7zip/Archive/GZip/GZipHandler.h b/CPP/7zip/Archive/GZip/GZipHandler.h
index ace3c657..c1f8968b 100755
--- a/CPP/7zip/Archive/GZip/GZipHandler.h
+++ b/CPP/7zip/Archive/GZip/GZipHandler.h
@@ -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;
}
};
diff --git a/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp b/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
index 906a324a..76cfd642 100755
--- a/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
@@ -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;
}
diff --git a/CPP/7zip/Archive/GZip/GZipIn.cpp b/CPP/7zip/Archive/GZip/GZipIn.cpp
index 69eb491e..44ed62f6 100755
--- a/CPP/7zip/Archive/GZip/GZipIn.cpp
+++ b/CPP/7zip/Archive/GZip/GZipIn.cpp
@@ -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)
diff --git a/CPP/7zip/Archive/GZip/GZipUpdate.cpp b/CPP/7zip/Archive/GZip/GZipUpdate.cpp
index c9567245..17e27c9f 100755
--- a/CPP/7zip/Archive/GZip/GZipUpdate.cpp
+++ b/CPP/7zip/Archive/GZip/GZipUpdate.cpp
@@ -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
diff --git a/CPP/7zip/Archive/GZip/GZipUpdate.h b/CPP/7zip/Archive/GZip/GZipUpdate.h
index 7ab92848..27a396bf 100755
--- a/CPP/7zip/Archive/GZip/GZipUpdate.h
+++ b/CPP/7zip/Archive/GZip/GZipUpdate.h
@@ -17,6 +17,7 @@ struct CCompressionMethodMode
{
UInt32 NumPasses;
UInt32 NumFastBytes;
+ UInt32 Algo;
bool NumMatchFinderCyclesDefined;
UInt32 NumMatchFinderCycles;
};
diff --git a/CPP/7zip/Archive/IArchive.h b/CPP/7zip/Archive/IArchive.h
index d6cbe804..3ef26a75 100755
--- a/CPP/7zip/Archive/IArchive.h
+++ b/CPP/7zip/Archive/IArchive.h
@@ -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
};
}
}
diff --git a/CPP/7zip/Archive/Iso/IsoHandler.h b/CPP/7zip/Archive/Iso/IsoHandler.h
index e545d2a7..07d75844 100755
--- a/CPP/7zip/Archive/Iso/IsoHandler.h
+++ b/CPP/7zip/Archive/Iso/IsoHandler.h
@@ -1,4 +1,4 @@
-// Tar/Handler.h
+// Iso/Handler.h
#ifndef __ISO_HANDLER_H
#define __ISO_HANDLER_H
diff --git a/CPP/7zip/Archive/Lzh/LzhHandler.h b/CPP/7zip/Archive/Lzh/LzhHandler.h
index 2dc89494..35929793 100755
--- a/CPP/7zip/Archive/Lzh/LzhHandler.h
+++ b/CPP/7zip/Archive/Lzh/LzhHandler.h
@@ -15,7 +15,7 @@ class CHandler:
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP
+ MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *inStream,
const UInt64 *maxCheckStartPosition,
diff --git a/CPP/7zip/Archive/Nsis/NsisHandler.h b/CPP/7zip/Archive/Nsis/NsisHandler.h
index e57cbad8..e180f70d 100755
--- a/CPP/7zip/Archive/Nsis/NsisHandler.h
+++ b/CPP/7zip/Archive/Nsis/NsisHandler.h
@@ -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
diff --git a/CPP/7zip/Archive/Nsis/NsisIn.cpp b/CPP/7zip/Archive/Nsis/NsisIn.cpp
index f14bf47c..8797a8e7 100755
--- a/CPP/7zip/Archive/Nsis/NsisIn.cpp
+++ b/CPP/7zip/Archive/Nsis/NsisIn.cpp
@@ -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[] =
{
diff --git a/CPP/7zip/Archive/RPM/RpmHandler.h b/CPP/7zip/Archive/RPM/RpmHandler.h
index 484c6c54..ed0717f3 100755
--- a/CPP/7zip/Archive/RPM/RpmHandler.h
+++ b/CPP/7zip/Archive/RPM/RpmHandler.h
@@ -14,7 +14,7 @@ class CHandler:
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP
+ MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp
index 5cd3c15d..7dbcee3d 100755
--- a/CPP/7zip/Archive/Rar/RarHandler.cpp
+++ b/CPP/7zip/Archive/Rar/RarHandler.cpp
@@ -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"
diff --git a/CPP/7zip/Archive/Rar/RarHandler.h b/CPP/7zip/Archive/Rar/RarHandler.h
index d54fd4e5..96d5d241 100755
--- a/CPP/7zip/Archive/Rar/RarHandler.h
+++ b/CPP/7zip/Archive/Rar/RarHandler.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
diff --git a/CPP/7zip/Archive/Rar/RarIn.cpp b/CPP/7zip/Archive/Rar/RarIn.cpp
index b87199ce..7340cc1f 100755
--- a/CPP/7zip/Archive/Rar/RarIn.cpp
+++ b/CPP/7zip/Archive/Rar/RarIn.cpp
@@ -17,8 +17,6 @@ extern "C"
namespace NArchive {
namespace NRar {
-static const char kEndOfString = '\0';
-
void CInArchive::ThrowExceptionWithCode(
CInArchiveException::CCauseType cause)
{
diff --git a/CPP/7zip/Archive/Rar/RarIn.h b/CPP/7zip/Archive/Rar/RarIn.h
index 22262a74..83a4d193 100755
--- a/CPP/7zip/Archive/Rar/RarIn.h
+++ b/CPP/7zip/Archive/Rar/RarIn.h
@@ -24,7 +24,7 @@ public:
kUnexpectedEndOfArchive = 0,
kArchiveHeaderCRCError,
kFileHeaderCRCError,
- kIncorrectArchive,
+ kIncorrectArchive
}
Cause;
CInArchiveException(CCauseType cause) : Cause(cause) {}
diff --git a/CPP/7zip/Archive/Split/SplitHandler.h b/CPP/7zip/Archive/Split/SplitHandler.h
index 8b3fcb70..a98dc0a6 100755
--- a/CPP/7zip/Archive/Split/SplitHandler.h
+++ b/CPP/7zip/Archive/Split/SplitHandler.h
@@ -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,
diff --git a/CPP/7zip/Archive/Z/ZHandler.h b/CPP/7zip/Archive/Z/ZHandler.h
index 7abba29f..21165390 100755
--- a/CPP/7zip/Archive/Z/ZHandler.h
+++ b/CPP/7zip/Archive/Z/ZHandler.h
@@ -14,7 +14,7 @@ class CHandler:
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP
+ MY_UNKNOWN_IMP1(IInArchive)
STDMETHOD(Open)(IInStream *stream,
const UInt64 *maxCheckStartPosition,
diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
index 9d8737d8..0344f776 100755
--- a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
@@ -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
diff --git a/CPP/7zip/Archive/Zip/ZipCompressionMode.h b/CPP/7zip/Archive/Zip/ZipCompressionMode.h
index f1c79918..650d4f35 100755
--- a/CPP/7zip/Archive/Zip/ZipCompressionMode.h
+++ b/CPP/7zip/Archive/Zip/ZipCompressionMode.h
@@ -13,6 +13,7 @@ struct CCompressionMethodMode
{
CRecordVector<Byte> MethodSequence;
// bool MaximizeRatio;
+ UInt32 Algo;
UInt32 NumPasses;
UInt32 NumFastBytes;
bool NumMatchFinderCyclesDefined;
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp
index 7f906999..c1185363 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp
@@ -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;
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.h b/CPP/7zip/Archive/Zip/ZipHandler.h
index 45dc8ad6..f7bf4cf1 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.h
+++ b/CPP/7zip/Archive/Zip/ZipHandler.h
@@ -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 =
diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
index ba5199dc..0ccd3727 100755
--- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
@@ -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;
}
diff --git a/CPP/7zip/Archive/Zip/ZipItem.cpp b/CPP/7zip/Archive/Zip/ZipItem.cpp
index 1934c357..86c2764b 100755
--- a/CPP/7zip/Archive/Zip/ZipItem.cpp
+++ b/CPP/7zip/Archive/Zip/ZipItem.cpp
@@ -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());
diff --git a/CPP/7zip/Archive/Zip/ZipUpdate.cpp b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
index e14cd693..8caa1409 100755
--- a/CPP/7zip/Archive/Zip/ZipUpdate.cpp
+++ b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
@@ -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;
}