diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2008-08-13 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:15:56 +0300 |
commit | 173c07e166fdf6fcd20f18ea73008f1b628945df (patch) | |
tree | 13ebea85cdc4c16ae93714ff0627ee9f91ad7e08 /CPP/7zip/Archive/Common | |
parent | 3901bf0ab88106a5b031cba7bc18d60cdebf7eef (diff) |
4.59 beta
Diffstat (limited to 'CPP/7zip/Archive/Common')
22 files changed, 213 insertions, 141 deletions
diff --git a/CPP/7zip/Archive/Common/CoderMixer.cpp b/CPP/7zip/Archive/Common/CoderMixer.cpp index db626fe1..a19f0457 100755 --- a/CPP/7zip/Archive/Common/CoderMixer.cpp +++ b/CPP/7zip/Archive/Common/CoderMixer.cpp @@ -16,4 +16,4 @@ void CCoderInfo::SetCoderInfo(const UInt64 *inSize, const UInt64 *outSize) OutSizeValue = *outSize; } -} +} diff --git a/CPP/7zip/Archive/Common/CoderMixer2.cpp b/CPP/7zip/Archive/Common/CoderMixer2.cpp index d11e9e60..aed94f9c 100755 --- a/CPP/7zip/Archive/Common/CoderMixer2.cpp +++ b/CPP/7zip/Archive/Common/CoderMixer2.cpp @@ -81,7 +81,7 @@ void CBindReverseConverter::CreateReverseBindInfo(CBindInfo &destBindInfo) destBindInfo.InStreams.Add(_srcOutToDestInMap[_srcBindInfo.OutStreams[i]]); } -CCoderInfo2::CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams): +CCoderInfo2::CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams): NumInStreams(numInStreams), NumOutStreams(numOutStreams) { @@ -91,7 +91,7 @@ CCoderInfo2::CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams): OutSizePointers.Reserve(NumOutStreams); } -static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes, +static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes, CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems) { sizes.Clear(); @@ -118,4 +118,4 @@ void CCoderInfo2::SetCoderInfo(const UInt64 **inSizes, SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams); } -} +} diff --git a/CPP/7zip/Archive/Common/CoderMixer2.h b/CPP/7zip/Archive/Common/CoderMixer2.h index be68c680..a03722d6 100755 --- a/CPP/7zip/Archive/Common/CoderMixer2.h +++ b/CPP/7zip/Archive/Common/CoderMixer2.h @@ -92,7 +92,7 @@ struct CBindInfo } - void FindInStream(UInt32 streamIndex, UInt32 &coderIndex, + void FindInStream(UInt32 streamIndex, UInt32 &coderIndex, UInt32 &coderStreamIndex) const { for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++) @@ -107,7 +107,7 @@ struct CBindInfo } throw 1; } - void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex, + void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex, UInt32 &coderStreamIndex) const { for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++) diff --git a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp index e1030976..1265dfcd 100755 --- a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp +++ b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp @@ -6,7 +6,7 @@ namespace NCoderMixer { -CCoder2::CCoder2(UInt32 numInStreams, UInt32 numOutStreams): +CCoder2::CCoder2(UInt32 numInStreams, UInt32 numOutStreams): CCoderInfo2(numInStreams, numOutStreams) { InStreams.Reserve(NumInStreams); @@ -35,7 +35,7 @@ void CCoder2::Code(ICompressProgressInfo *progress) OutStreamPointers.Add((ISequentialOutStream *)OutStreams[i]); } if (Coder) - Result = Coder->Code(InStreamPointers[0], OutStreamPointers[0], + Result = Coder->Code(InStreamPointers[0], OutStreamPointers[0], InSizePointers[0], OutSizePointers[0], progress); else Result = Coder2->Code(&InStreamPointers.Front(), &InSizePointers.Front(), NumInStreams, @@ -49,7 +49,7 @@ void CCoder2::Code(ICompressProgressInfo *progress) } } -static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes, +static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes, CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems) { sizes.Clear(); @@ -80,8 +80,8 @@ void CCoder2::SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes) // CCoderMixer2MT HRESULT CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo) -{ - _bindInfo = bindInfo; +{ + _bindInfo = bindInfo; _streamBinders.Clear(); for(int i = 0; i < _bindInfo.BindPairs.Size(); i++) { @@ -118,7 +118,7 @@ void CCoderMixer2MT::ReInit() } -HRESULT CCoderMixer2MT::Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams) +HRESULT CCoderMixer2MT::Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams) { /* if (_coders.Size() != _bindInfo.Coders.Size()) @@ -176,9 +176,9 @@ HRESULT CCoderMixer2MT::ReturnIfError(HRESULT code) } STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams, - const UInt64 ** /* inSizes */, + const UInt64 ** /* inSizes */, UInt32 numInStreams, - ISequentialOutStream **outStreams, + ISequentialOutStream **outStreams, const UInt64 ** /* outSizes */, UInt32 numOutStreams, ICompressProgressInfo *progress) @@ -227,4 +227,4 @@ STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams, return S_OK; } -} +} diff --git a/CPP/7zip/Archive/Common/CoderMixer2MT.h b/CPP/7zip/Archive/Common/CoderMixer2MT.h index 505f1a88..d1c7f4d0 100755 --- a/CPP/7zip/Archive/Common/CoderMixer2MT.h +++ b/CPP/7zip/Archive/Common/CoderMixer2MT.h @@ -35,7 +35,7 @@ struct CCoder2: public CCoderInfo2, public CVirtThread { ReInit() for each coder - SetCoderInfo + SetCoderInfo Code } */ @@ -57,9 +57,9 @@ public: MY_UNKNOWN_IMP STDMETHOD(Code)(ISequentialInStream **inStreams, - const UInt64 **inSizes, + const UInt64 **inSizes, UInt32 numInStreams, - ISequentialOutStream **outStreams, + ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams, ICompressProgressInfo *progress); diff --git a/CPP/7zip/Archive/Common/CoderMixer2ST.cpp b/CPP/7zip/Archive/Common/CoderMixer2ST.cpp index 6bcab0dd..a59ce5fc 100755 --- a/CPP/7zip/Archive/Common/CoderMixer2ST.cpp +++ b/CPP/7zip/Archive/Common/CoderMixer2ST.cpp @@ -11,9 +11,9 @@ CCoderMixer2ST::CCoderMixer2ST() {} CCoderMixer2ST::~CCoderMixer2ST(){ } HRESULT CCoderMixer2ST::SetBindInfo(const CBindInfo &bindInfo) -{ - _bindInfo = bindInfo; - return S_OK; +{ + _bindInfo = bindInfo; + return S_OK; } void CCoderMixer2ST::AddCoderCommon(bool isMain) @@ -37,7 +37,7 @@ void CCoderMixer2ST::AddCoder2(ICompressCoder2 *coder, bool isMain) void CCoderMixer2ST::ReInit() { } HRESULT CCoderMixer2ST::GetInStream( - ISequentialInStream **inStreams, const UInt64 **inSizes, + ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 streamIndex, ISequentialInStream **inStreamRes) { CMyComPtr<ISequentialInStream> seqInStream; @@ -54,7 +54,7 @@ HRESULT CCoderMixer2ST::GetInStream( return E_INVALIDARG; UInt32 coderIndex, coderStreamIndex; - _bindInfo.FindOutStream(_bindInfo.BindPairs[binderIndex].OutIndex, + _bindInfo.FindOutStream(_bindInfo.BindPairs[binderIndex].OutIndex, coderIndex, coderStreamIndex); CCoderInfo &coder = _coders[coderIndex]; @@ -86,7 +86,7 @@ HRESULT CCoderMixer2ST::GetInStream( } HRESULT CCoderMixer2ST::GetOutStream( - ISequentialOutStream **outStreams, const UInt64 **outSizes, + ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 streamIndex, ISequentialOutStream **outStreamRes) { CMyComPtr<ISequentialOutStream> seqOutStream; @@ -103,7 +103,7 @@ HRESULT CCoderMixer2ST::GetOutStream( return E_INVALIDARG; UInt32 coderIndex, coderStreamIndex; - _bindInfo.FindInStream(_bindInfo.BindPairs[binderIndex].InIndex, + _bindInfo.FindInStream(_bindInfo.BindPairs[binderIndex].InIndex, coderIndex, coderStreamIndex); CCoderInfo &coder = _coders[coderIndex]; @@ -136,9 +136,9 @@ HRESULT CCoderMixer2ST::GetOutStream( STDMETHODIMP CCoderMixer2ST::Code(ISequentialInStream **inStreams, - const UInt64 **inSizes, + const UInt64 **inSizes, UInt32 numInStreams, - ISequentialOutStream **outStreams, + ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams, ICompressProgressInfo *progress) @@ -216,9 +216,9 @@ STDMETHODIMP CCoderMixer2ST::Code(ISequentialInStream **inStreams, else { RINOK(mainCoder.Coder2->Code( - &seqInStreamsSpec.Front(), + &seqInStreamsSpec.Front(), &mainCoder.InSizePointers.Front(), mainCoder.NumInStreams, - &seqOutStreamsSpec.Front(), + &seqOutStreamsSpec.Front(), &mainCoder.OutSizePointers.Front(), mainCoder.NumOutStreams, progress)); } @@ -236,4 +236,4 @@ UInt64 CCoderMixer2ST::GetWriteProcessedSize(UInt32 binderIndex) const } */ -} +} diff --git a/CPP/7zip/Archive/Common/CoderMixer2ST.h b/CPP/7zip/Archive/Common/CoderMixer2ST.h index ea5a53e3..a4ea7e80 100755 --- a/CPP/7zip/Archive/Common/CoderMixer2ST.h +++ b/CPP/7zip/Archive/Common/CoderMixer2ST.h @@ -14,13 +14,13 @@ namespace NCoderMixer2 { // { // AddCoder[2]() // } -// +// // for each file // { // ReInit() // for each coder // { -// SetCoderInfo +// SetCoderInfo // } // SetProgressIndex(UInt32 coderIndex); // Code @@ -41,16 +41,16 @@ class CCoderMixer2ST: MY_UNKNOWN_IMP HRESULT GetInStream( - ISequentialInStream **inStreams, const UInt64 **inSizes, + ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 streamIndex, ISequentialInStream **inStreamRes); HRESULT GetOutStream( - ISequentialOutStream **outStreams, const UInt64 **outSizes, + ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 streamIndex, ISequentialOutStream **outStreamRes); public: STDMETHOD(Code)(ISequentialInStream **inStreams, - const UInt64 **inSizes, + const UInt64 **inSizes, UInt32 numInStreams, - ISequentialOutStream **outStreams, + ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams, ICompressProgressInfo *progress); @@ -63,13 +63,13 @@ public: void ReInit(); void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) - { + { { _coders[coderIndex].SetCoderInfo(inSizes, outSizes); } } void SetProgressCoderIndex(UInt32 /*coderIndex*/) - { - // _progressCoderIndex = coderIndex; + { + // _progressCoderIndex = coderIndex; } // UInt64 GetWriteProcessedSize(UInt32 binderIndex) const; diff --git a/CPP/7zip/Archive/Common/CoderMixerMT.cpp b/CPP/7zip/Archive/Common/CoderMixerMT.cpp index 85cf0a52..f43d1612 100755 --- a/CPP/7zip/Archive/Common/CoderMixerMT.cpp +++ b/CPP/7zip/Archive/Common/CoderMixerMT.cpp @@ -10,9 +10,9 @@ void CCoder::Execute() { Code(NULL); } void CCoder::Code(ICompressProgressInfo *progress) { - Result = Coder->Code(InStream, OutStream, - InSizeAssigned ? &InSizeValue : NULL, - OutSizeAssigned ? &OutSizeValue : NULL, + Result = Coder->Code(InStream, OutStream, + InSizeAssigned ? &InSizeValue : NULL, + OutSizeAssigned ? &OutSizeValue : NULL, progress); InStream.Release(); OutStream.Release(); @@ -39,7 +39,7 @@ HRESULT CCoderMixerMT::ReturnIfError(HRESULT code) } STDMETHODIMP CCoderMixerMT::Code(ISequentialInStream *inStream, - ISequentialOutStream *outStream, + ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress) { @@ -96,4 +96,4 @@ STDMETHODIMP CCoderMixerMT::Code(ISequentialInStream *inStream, return S_OK; } -} +} diff --git a/CPP/7zip/Archive/Common/CoderMixerMT.h b/CPP/7zip/Archive/Common/CoderMixerMT.h index 6fd1ba44..c70e1829 100755 --- a/CPP/7zip/Archive/Common/CoderMixerMT.h +++ b/CPP/7zip/Archive/Common/CoderMixerMT.h @@ -29,7 +29,7 @@ struct CCoder: public CCoderInfo, public CVirtThread { ReInit() for each coder - SetCoderInfo + SetCoderInfo Code } */ @@ -48,7 +48,7 @@ public: MY_UNKNOWN_IMP STDMETHOD(Code)(ISequentialInStream *inStream, - ISequentialOutStream *outStream, + ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); diff --git a/CPP/7zip/Archive/Common/CrossThreadProgress.h b/CPP/7zip/Archive/Common/CrossThreadProgress.h index b5422a31..7e0b1053 100755 --- a/CPP/7zip/Archive/Common/CrossThreadProgress.h +++ b/CPP/7zip/Archive/Common/CrossThreadProgress.h @@ -7,7 +7,7 @@ #include "../../../Windows/Synchronization.h" #include "../../../Common/MyCom.h" -class CCrossThreadProgress: +class CCrossThreadProgress: public ICompressProgressInfo, public CMyUnknownImp { diff --git a/CPP/7zip/Archive/Common/DummyOutStream.h b/CPP/7zip/Archive/Common/DummyOutStream.h index d19b3111..13d5b62c 100755 --- a/CPP/7zip/Archive/Common/DummyOutStream.h +++ b/CPP/7zip/Archive/Common/DummyOutStream.h @@ -6,7 +6,7 @@ #include "../../IStream.h" #include "Common/MyCom.h" -class CDummyOutStream: +class CDummyOutStream: public ISequentialOutStream, public CMyUnknownImp { @@ -14,6 +14,7 @@ class CDummyOutStream: UInt64 _size; public: void SetStream(ISequentialOutStream *outStream) { _stream = outStream; } + void ReleaseStream() { _stream.Release(); } void Init() { _size = 0; } MY_UNKNOWN_IMP STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); diff --git a/CPP/7zip/Archive/Common/FindSignature.cpp b/CPP/7zip/Archive/Common/FindSignature.cpp new file mode 100755 index 00000000..15aa6cea --- /dev/null +++ b/CPP/7zip/Archive/Common/FindSignature.cpp @@ -0,0 +1,62 @@ +// FindSignature.cpp + +#include "StdAfx.h" + +#include "Common/Buffer.h" + +#include "FindSignature.h" + +#include "../../Common/StreamUtils.h" + +HRESULT FindSignatureInStream(ISequentialInStream *stream, + const Byte *signature, unsigned signatureSize, + const UInt64 *limit, UInt64 &resPos) +{ + resPos = 0; + CByteBuffer byteBuffer2; + byteBuffer2.SetCapacity(signatureSize); + RINOK(ReadStream_FALSE(stream, byteBuffer2, signatureSize)); + + if (memcmp(byteBuffer2, signature, signatureSize) == 0) + return S_OK; + + const UInt32 kBufferSize = (1 << 16); + CByteBuffer byteBuffer; + byteBuffer.SetCapacity(kBufferSize); + Byte *buffer = byteBuffer; + UInt32 numPrevBytes = signatureSize - 1; + memcpy(buffer, (const Byte *)byteBuffer2 + 1, numPrevBytes); + resPos = 1; + for (;;) + { + if (limit != NULL) + if (resPos > *limit) + return S_FALSE; + do + { + UInt32 numReadBytes = kBufferSize - numPrevBytes; + UInt32 processedSize; + RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize)); + numPrevBytes += processedSize; + if (processedSize == 0) + return S_FALSE; + } + while (numPrevBytes < signatureSize); + UInt32 numTests = numPrevBytes - signatureSize + 1; + for (UInt32 pos = 0; pos < numTests; pos++) + { + Byte b = signature[0]; + for (; buffer[pos] != b && pos < numTests; pos++); + if (pos == numTests) + break; + if (memcmp(buffer + pos, signature, signatureSize) == 0) + { + resPos += pos; + return S_OK; + } + } + resPos += numTests; + numPrevBytes -= numTests; + memmove(buffer, buffer + numTests, numPrevBytes); + } +} diff --git a/CPP/7zip/Archive/Common/FindSignature.h b/CPP/7zip/Archive/Common/FindSignature.h new file mode 100755 index 00000000..e15af573 --- /dev/null +++ b/CPP/7zip/Archive/Common/FindSignature.h @@ -0,0 +1,12 @@ +// FindSignature.h + +#ifndef __FINDSIGNATURE_H +#define __FINDSIGNATURE_H + +#include "../../IStream.h" + +HRESULT FindSignatureInStream(ISequentialInStream *stream, + const Byte *signature, unsigned signatureSize, + const UInt64 *limit, UInt64 &resPos); + +#endif diff --git a/CPP/7zip/Archive/Common/HandlerOut.cpp b/CPP/7zip/Archive/Common/HandlerOut.cpp index 082a484d..63899fe4 100755 --- a/CPP/7zip/Archive/Common/HandlerOut.cpp +++ b/CPP/7zip/Archive/Common/HandlerOut.cpp @@ -79,10 +79,10 @@ static bool AreEqual(const UString &methodName, const wchar_t *s) { return (methodName.CompareNoCase(s) == 0); } static inline bool IsLZMAMethod(const UString &methodName) -{ - return - AreEqual(methodName, kLZMAMethodName) || - AreEqual(methodName, kLZMA2MethodName); +{ + return + AreEqual(methodName, kLZMAMethodName) || + AreEqual(methodName, kLZMA2MethodName); } static inline bool IsBZip2Method(const UString &methodName) @@ -92,10 +92,10 @@ static inline bool IsPpmdMethod(const UString &methodName) { return AreEqual(methodName, kPpmdMethodName); } static inline bool IsDeflateMethod(const UString &methodName) -{ - return - AreEqual(methodName, kDeflateMethodName) || - AreEqual(methodName, kDeflate64MethodName); +{ + return + AreEqual(methodName, kDeflateMethodName) || + AreEqual(methodName, kDeflate64MethodName); } struct CNameToPropID @@ -105,7 +105,7 @@ struct CNameToPropID const wchar_t *Name; }; -CNameToPropID g_NameToPropID[] = +CNameToPropID g_NameToPropID[] = { { NCoderPropID::kOrder, VT_UI4, L"O" }, { NCoderPropID::kPosStateBits, VT_UI4, L"PB" }, @@ -158,7 +158,7 @@ static int FindPropIdFromStringName(const UString &name) return -1; } -static void SetOneMethodProp(COneMethodInfo &oneMethodInfo, PROPID propID, +static void SetOneMethodProp(COneMethodInfo &oneMethodInfo, PROPID propID, const NWindows::NCOM::CPropVariant &value) { for (int j = 0; j < oneMethodInfo.Properties.Size(); j++) @@ -182,24 +182,24 @@ void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo if (IsLZMAMethod(oneMethodInfo.MethodName)) { - UInt32 dicSize = - (level >= 9 ? kLzmaDicSizeX9 : - (level >= 7 ? kLzmaDicSizeX7 : - (level >= 5 ? kLzmaDicSizeX5 : - (level >= 3 ? kLzmaDicSizeX3 : - kLzmaDicSizeX1)))); + UInt32 dicSize = + (level >= 9 ? kLzmaDicSizeX9 : + (level >= 7 ? kLzmaDicSizeX7 : + (level >= 5 ? kLzmaDicSizeX5 : + (level >= 3 ? kLzmaDicSizeX3 : + kLzmaDicSizeX1)))); - UInt32 algo = - (level >= 5 ? kLzmaAlgoX5 : - kLzmaAlgoX1); + UInt32 algo = + (level >= 5 ? kLzmaAlgoX5 : + kLzmaAlgoX1); - UInt32 fastBytes = - (level >= 7 ? kLzmaFastBytesX7 : - kLzmaFastBytesX1); + UInt32 fastBytes = + (level >= 7 ? kLzmaFastBytesX7 : + kLzmaFastBytesX1); - const wchar_t *matchFinder = - (level >= 5 ? kLzmaMatchFinderX5 : - kLzmaMatchFinderX1); + const wchar_t *matchFinder = + (level >= 5 ? kLzmaMatchFinderX5 : + kLzmaMatchFinderX1); SetOneMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize); SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algo); @@ -211,19 +211,19 @@ void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo } else if (IsDeflateMethod(oneMethodInfo.MethodName)) { - UInt32 fastBytes = - (level >= 9 ? kDeflateFastBytesX9 : - (level >= 7 ? kDeflateFastBytesX7 : + UInt32 fastBytes = + (level >= 9 ? kDeflateFastBytesX9 : + (level >= 7 ? kDeflateFastBytesX7 : kDeflateFastBytesX1)); - UInt32 numPasses = - (level >= 9 ? kDeflatePassesX9 : - (level >= 7 ? kDeflatePassesX7 : + UInt32 numPasses = + (level >= 9 ? kDeflatePassesX9 : + (level >= 7 ? kDeflatePassesX7 : kDeflatePassesX1)); - UInt32 algo = - (level >= 5 ? kDeflateAlgoX5 : - kDeflateAlgoX1); + UInt32 algo = + (level >= 5 ? kDeflateAlgoX5 : + kDeflateAlgoX1); SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algo); SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes); @@ -231,14 +231,14 @@ void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo } else if (IsBZip2Method(oneMethodInfo.MethodName)) { - UInt32 numPasses = - (level >= 9 ? kBZip2NumPassesX9 : - (level >= 7 ? kBZip2NumPassesX7 : + UInt32 numPasses = + (level >= 9 ? kBZip2NumPassesX9 : + (level >= 7 ? kBZip2NumPassesX7 : kBZip2NumPassesX1)); - UInt32 dicSize = - (level >= 5 ? kBZip2DicSizeX5 : - (level >= 3 ? kBZip2DicSizeX3 : + UInt32 dicSize = + (level >= 5 ? kBZip2DicSizeX5 : + (level >= 3 ? kBZip2DicSizeX3 : kBZip2DicSizeX1)); SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses); @@ -249,16 +249,16 @@ void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo } else if (IsPpmdMethod(oneMethodInfo.MethodName)) { - UInt32 useMemSize = - (level >= 9 ? kPpmdMemSizeX9 : - (level >= 7 ? kPpmdMemSizeX7 : - (level >= 5 ? kPpmdMemSizeX5 : + UInt32 useMemSize = + (level >= 9 ? kPpmdMemSizeX9 : + (level >= 7 ? kPpmdMemSizeX7 : + (level >= 5 ? kPpmdMemSizeX5 : kPpmdMemSizeX1))); - UInt32 order = - (level >= 9 ? kPpmdOrderX9 : - (level >= 7 ? kPpmdOrderX7 : - (level >= 5 ? kPpmdOrderX5 : + UInt32 order = + (level >= 9 ? kPpmdOrderX9 : + (level >= 7 ? kPpmdOrderX7 : + (level >= 5 ? kPpmdOrderX5 : kPpmdOrderX1))); SetOneMethodProp(oneMethodInfo, NCoderPropID::kUsedMemorySize, useMemSize); @@ -313,7 +313,7 @@ HRESULT COutHandler::SetParam(COneMethodInfo &oneMethodInfo, const UString &name { CProp property; if ( - name.CompareNoCase(L"D") == 0 || + name.CompareNoCase(L"D") == 0 || name.CompareNoCase(L"MEM") == 0) { UInt32 dicSize; @@ -457,11 +457,12 @@ void COutHandler::Init() { _removeSfxBlock = false; _compressHeaders = true; + _encryptHeadersSpecified = false; _encryptHeaders = false; - WriteModified = true; - WriteCreated = false; - WriteAccessed = false; + WriteCTime = false; + WriteATime = false; + WriteMTime = true; #ifdef COMPRESS_MT _numThreads = NWindows::NSystem::GetNumberOfProcessors(); @@ -530,12 +531,9 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val #endif return S_OK; } - if (name.CompareNoCase(L"RSFX") == 0) - return SetBoolProperty(_removeSfxBlock, value); - if (name.CompareNoCase(L"F") == 0) - return SetBoolProperty(_autoFilter, value); - if (name.CompareNoCase(L"HC") == 0) - return SetBoolProperty(_compressHeaders, value); + if (name.CompareNoCase(L"RSFX") == 0) return SetBoolProperty(_removeSfxBlock, value); + if (name.CompareNoCase(L"F") == 0) return SetBoolProperty(_autoFilter, value); + if (name.CompareNoCase(L"HC") == 0) return SetBoolProperty(_compressHeaders, value); if (name.CompareNoCase(L"HCF") == 0) { bool compressHeadersFull = true; @@ -545,15 +543,15 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val return S_OK; } if (name.CompareNoCase(L"HE") == 0) - return SetBoolProperty(_encryptHeaders, value); - if (name.CompareNoCase(L"TM") == 0) - return SetBoolProperty(WriteModified, value); - if (name.CompareNoCase(L"TC") == 0) - return SetBoolProperty(WriteCreated, value); - if (name.CompareNoCase(L"TA") == 0) - return SetBoolProperty(WriteAccessed, value); - if (name.CompareNoCase(L"V") == 0) - return SetBoolProperty(_volumeMode, value); + { + RINOK(SetBoolProperty(_encryptHeaders, value)); + _encryptHeadersSpecified = true; + return S_OK; + } + if (name.CompareNoCase(L"TC") == 0) return SetBoolProperty(WriteCTime, value); + if (name.CompareNoCase(L"TA") == 0) return SetBoolProperty(WriteATime, value); + if (name.CompareNoCase(L"TM") == 0) return SetBoolProperty(WriteMTime, value); + if (name.CompareNoCase(L"V") == 0) return SetBoolProperty(_volumeMode, value); number = 0; } if (number > 10000) @@ -623,6 +621,6 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val } } return S_OK; -} +} } diff --git a/CPP/7zip/Archive/Common/HandlerOut.h b/CPP/7zip/Archive/Common/HandlerOut.h index ab925cc3..b6095a6b 100755 --- a/CPP/7zip/Archive/Common/HandlerOut.h +++ b/CPP/7zip/Archive/Common/HandlerOut.h @@ -4,7 +4,7 @@ #define __HANDLER_OUT_H #include "../../Common/MethodProps.h" -#include "../../Common/CreateCoder.h" +#include "../../../Common/MyString.h" namespace NArchive { @@ -31,17 +31,18 @@ public: CObjectVector<COneMethodInfo> _methods; bool _removeSfxBlock; - UInt64 _numSolidFiles; + UInt64 _numSolidFiles; UInt64 _numSolidBytes; bool _numSolidBytesDefined; bool _solidExtension; bool _compressHeaders; + bool _encryptHeadersSpecified; bool _encryptHeaders; - bool WriteModified; - bool WriteCreated; - bool WriteAccessed; + bool WriteCTime; + bool WriteATime; + bool WriteMTime; bool _autoFilter; UInt32 _level; @@ -77,8 +78,6 @@ public: UInt32 numProcessors; UInt32 mainDicSize; UInt32 mainDicMethodIndex; - - DECL_EXTERNAL_CODECS_VARS }; } diff --git a/CPP/7zip/Archive/Common/InStreamWithCRC.h b/CPP/7zip/Archive/Common/InStreamWithCRC.h index 96bea9b2..c5ada6fe 100755 --- a/CPP/7zip/Archive/Common/InStreamWithCRC.h +++ b/CPP/7zip/Archive/Common/InStreamWithCRC.h @@ -6,12 +6,12 @@ #include "../../../Common/MyCom.h" #include "../../IStream.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/7zCrc.h" } -class CSequentialInStreamWithCRC: +class CSequentialInStreamWithCRC: public ISequentialInStream, public CMyUnknownImp { @@ -38,7 +38,7 @@ public: bool WasFinished() const { return _wasFinished; } }; -class CInStreamWithCRC: +class CInStreamWithCRC: public IInStream, public CMyUnknownImp { diff --git a/CPP/7zip/Archive/Common/ItemNameUtils.cpp b/CPP/7zip/Archive/Common/ItemNameUtils.cpp index f7c3fcd9..6dfaf980 100755 --- a/CPP/7zip/Archive/Common/ItemNameUtils.cpp +++ b/CPP/7zip/Archive/Common/ItemNameUtils.cpp @@ -38,7 +38,7 @@ bool HasTailSlash(const AString &name, UINT codePage) { if (name.IsEmpty()) return false; - LPCSTR prev = + LPCSTR prev = #ifdef _WIN32 CharPrevExA((WORD)codePage, name, &name[name.Length()], 0); #else diff --git a/CPP/7zip/Archive/Common/MultiStream.cpp b/CPP/7zip/Archive/Common/MultiStream.cpp index a8cb333e..cf7dc050 100755 --- a/CPP/7zip/Archive/Common/MultiStream.cpp +++ b/CPP/7zip/Archive/Common/MultiStream.cpp @@ -33,7 +33,7 @@ STDMETHODIMP CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize) return S_OK; } -STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin, +STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) { UInt64 newPos; @@ -76,7 +76,7 @@ STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin, /* -class COutVolumeStream: +class COutVolumeStream: public ISequentialOutStream, public CMyUnknownImp { @@ -93,9 +93,9 @@ public: CFileItem _file; CUpdateOptions _options; CMyComPtr<IArchiveUpdateCallback2> VolumeCallback; - void Init(IArchiveUpdateCallback2 *volumeCallback, - const UString &name) - { + void Init(IArchiveUpdateCallback2 *volumeCallback, + const UString &name) + { _file.Name = name; _file.IsStartPosDefined = true; _file.StartPos = 0; diff --git a/CPP/7zip/Archive/Common/MultiStream.h b/CPP/7zip/Archive/Common/MultiStream.h index b0fe41d6..137c9400 100755 --- a/CPP/7zip/Archive/Common/MultiStream.h +++ b/CPP/7zip/Archive/Common/MultiStream.h @@ -7,7 +7,7 @@ #include "../../../Common/MyVector.h" #include "../../Archive/IArchive.h" -class CMultiStream: +class CMultiStream: public IInStream, public CMyUnknownImp { @@ -40,7 +40,7 @@ public: }; /* -class COutMultiStream: +class COutMultiStream: public IOutStream, public CMyUnknownImp { diff --git a/CPP/7zip/Archive/Common/OutStreamWithCRC.h b/CPP/7zip/Archive/Common/OutStreamWithCRC.h index eaeecde7..32870235 100755 --- a/CPP/7zip/Archive/Common/OutStreamWithCRC.h +++ b/CPP/7zip/Archive/Common/OutStreamWithCRC.h @@ -6,12 +6,12 @@ #include "../../../Common/MyCom.h" #include "../../IStream.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/7zCrc.h" } -class COutStreamWithCRC: +class COutStreamWithCRC: public ISequentialOutStream, public CMyUnknownImp { diff --git a/CPP/7zip/Archive/Common/OutStreamWithSha1.h b/CPP/7zip/Archive/Common/OutStreamWithSha1.h index 976b347c..6df23080 100755 --- a/CPP/7zip/Archive/Common/OutStreamWithSha1.h +++ b/CPP/7zip/Archive/Common/OutStreamWithSha1.h @@ -11,7 +11,7 @@ #include "../../Crypto/Hash/Sha1.h" -class COutStreamWithSha1: +class COutStreamWithSha1: public ISequentialOutStream, public CMyUnknownImp { diff --git a/CPP/7zip/Archive/Common/ParseProperties.cpp b/CPP/7zip/Archive/Common/ParseProperties.cpp index 83d51241..5cd849e2 100755 --- a/CPP/7zip/Archive/Common/ParseProperties.cpp +++ b/CPP/7zip/Archive/Common/ParseProperties.cpp @@ -138,7 +138,7 @@ int ParseStringToUInt32(const UString &srcString, UInt32 &number) const wchar_t *start = srcString; const wchar_t *end; UInt64 number64 = ConvertStringToUInt64(start, &end); - if (number64 > 0xFFFFFFFF) + if (number64 > 0xFFFFFFFF) { number = 0; return 0; @@ -158,7 +158,7 @@ HRESULT ParseMtProp(const UString &name, const PROPVARIANT &prop, UInt32 default break; default: { - bool val; + bool val; RINOK(SetBoolProperty(val, prop)); numThreads = (val ? defaultNumThreads : 1); break; |