diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2007-05-25 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:15:51 +0300 |
commit | c574fc0f4bba94e693b0e22f730d355b75d4f4ce (patch) | |
tree | da4ebd90c776d508ac679d50492f29461db80be0 /CPP/7zip/Archive/Zip | |
parent | a145bfc7cf17f7bbcfae8f0064333c8ea75b455c (diff) |
4.46 beta
Diffstat (limited to 'CPP/7zip/Archive/Zip')
-rwxr-xr-x | CPP/7zip/Archive/Zip/ZipAddCommon.cpp | 2 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Zip/ZipCompressionMode.h | 1 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Zip/ZipHandler.cpp | 2 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Zip/ZipHandler.h | 5 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Zip/ZipHandlerOut.cpp | 14 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Zip/ZipItem.cpp | 2 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Zip/ZipUpdate.cpp | 58 |
7 files changed, 39 insertions, 45 deletions
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; } |