diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2015-11-03 03:00:00 +0300 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:57 +0300 |
commit | 7c8a265a15125b64808e695882acd2a0298ebce4 (patch) | |
tree | 81fc9fdedc6b70b979a3dfe3a3041457a6e9468d /CPP | |
parent | a663a6deb7a150f935fac7efdbf4d53d27369594 (diff) |
15.1015.10
Diffstat (limited to 'CPP')
45 files changed, 775 insertions, 464 deletions
diff --git a/CPP/7zip/Archive/7z/7z.dsp b/CPP/7zip/Archive/7z/7z.dsp index 7fd1ccdc..ffd28721 100644 --- a/CPP/7zip/Archive/7z/7z.dsp +++ b/CPP/7zip/Archive/7z/7z.dsp @@ -158,14 +158,6 @@ SOURCE=.\7zFolderInStream.h # End Source File # Begin Source File -SOURCE=.\7zFolderOutStream.cpp -# End Source File -# Begin Source File - -SOURCE=.\7zFolderOutStream.h -# End Source File -# Begin Source File - SOURCE=.\7zHandler.cpp # End Source File # Begin Source File @@ -350,14 +342,6 @@ SOURCE=..\Common\CoderMixer2.h # End Source File # Begin Source File -SOURCE=..\Common\CrossThreadProgress.cpp -# End Source File -# Begin Source File - -SOURCE=..\Common\CrossThreadProgress.h -# End Source File -# Begin Source File - SOURCE=..\Common\HandlerOut.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/Archive/7z/7zExtract.cpp b/CPP/7zip/Archive/7z/7zExtract.cpp index d21bafdb..83965164 100644 --- a/CPP/7zip/Archive/7z/7zExtract.cpp +++ b/CPP/7zip/Archive/7z/7zExtract.cpp @@ -254,8 +254,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, lps->Init(extractCallback, false); CDecoder decoder( - #ifndef USE_MIXER_ST + #if !defined(USE_MIXER_MT) false + #elif !defined(USE_MIXER_ST) + true + #elif !defined(__7Z_SET_PROPERTIES) + #ifdef _7ZIP_ST + false + #else + true + #endif #else _useMultiThreadMixer #endif diff --git a/CPP/7zip/Archive/7z/7zFolderOutStream.cpp b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp deleted file mode 100644 index e63ee925..00000000 --- a/CPP/7zip/Archive/7z/7zFolderOutStream.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// 7zFolderOutStream.cpp - -#include "StdAfx.h" diff --git a/CPP/7zip/Archive/7z/7zFolderOutStream.h b/CPP/7zip/Archive/7z/7zFolderOutStream.h deleted file mode 100644 index a32b22e0..00000000 --- a/CPP/7zip/Archive/7z/7zFolderOutStream.h +++ /dev/null @@ -1,6 +0,0 @@ -// 7zFolderOutStream.h - -#ifndef __7Z_FOLDER_OUT_STREAM_H -#define __7Z_FOLDER_OUT_STREAM_H - -#endif diff --git a/CPP/7zip/Archive/7z/7zHandler.cpp b/CPP/7zip/Archive/7z/7zHandler.cpp index d397e818..a95fc6a0 100644 --- a/CPP/7zip/Archive/7z/7zHandler.cpp +++ b/CPP/7zip/Archive/7z/7zHandler.cpp @@ -36,10 +36,14 @@ CHandler::CHandler() #endif #ifdef EXTRACT_ONLY + _crcSize = 4; + #ifdef __7Z_SET_PROPERTIES _numThreads = NSystem::GetNumberOfProcessors(); + _useMultiThreadMixer = true; #endif + #endif } @@ -722,10 +726,14 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR return E_INVALIDARG; const PROPVARIANT &value = values[i]; UInt32 number; - int index = ParseStringToUInt32(name, number); + unsigned index = ParseStringToUInt32(name, number); if (index == 0) { - if (name.IsEqualTo("mtf")) return PROPVARIANT_to_bool(value, _useMultiThreadMixer); + if (name.IsEqualTo("mtf")) + { + RINOK(PROPVARIANT_to_bool(value, _useMultiThreadMixer)); + continue; + } if (name.IsPrefixedBy_Ascii_NoCase("mt")) { RINOK(ParseMtProp(name.Ptr(2), value, numProcessors, _numThreads)); diff --git a/CPP/7zip/Archive/7z/7zHandler.h b/CPP/7zip/Archive/7z/7zHandler.h index eb7791bc..d46401af 100644 --- a/CPP/7zip/Archive/7z/7zHandler.h +++ b/CPP/7zip/Archive/7z/7zHandler.h @@ -21,11 +21,11 @@ namespace N7z { #ifndef __7Z_SET_PROPERTIES #ifdef EXTRACT_ONLY -#if !defined(_7ZIP_ST) && !defined(_SFX) -#define __7Z_SET_PROPERTIES -#endif + #if !defined(_7ZIP_ST) && !defined(_SFX) + #define __7Z_SET_PROPERTIES + #endif #else -#define __7Z_SET_PROPERTIES + #define __7Z_SET_PROPERTIES #endif #endif diff --git a/CPP/7zip/Archive/7z/makefile b/CPP/7zip/Archive/7z/makefile index 49818371..a3b077da 100644 --- a/CPP/7zip/Archive/7z/makefile +++ b/CPP/7zip/Archive/7z/makefile @@ -13,7 +13,6 @@ AR_OBJS = \ $O\7zEncode.obj \ $O\7zExtract.obj \ $O\7zFolderInStream.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zHandlerOut.obj \ $O\7zHeader.obj \ @@ -65,7 +64,6 @@ COMPRESS_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\HandlerOut.obj \ $O\InStreamWithCRC.obj \ $O\ItemNameUtils.obj \ diff --git a/CPP/7zip/Archive/Common/CrossThreadProgress.cpp b/CPP/7zip/Archive/Common/CrossThreadProgress.cpp deleted file mode 100644 index a974b54c..00000000 --- a/CPP/7zip/Archive/Common/CrossThreadProgress.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// CrossThreadProgress.cpp - -#include "StdAfx.h" - -#include "CrossThreadProgress.h" - -STDMETHODIMP CCrossThreadProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) -{ - InSize = inSize; - OutSize = outSize; - ProgressEvent.Set(); - WaitEvent.Lock(); - return Result; -} - diff --git a/CPP/7zip/Archive/Common/CrossThreadProgress.h b/CPP/7zip/Archive/Common/CrossThreadProgress.h deleted file mode 100644 index 7e0b1053..00000000 --- a/CPP/7zip/Archive/Common/CrossThreadProgress.h +++ /dev/null @@ -1,37 +0,0 @@ -// CrossThreadProgress.h - -#ifndef __CROSSTHREADPROGRESS_H -#define __CROSSTHREADPROGRESS_H - -#include "../../ICoder.h" -#include "../../../Windows/Synchronization.h" -#include "../../../Common/MyCom.h" - -class CCrossThreadProgress: - public ICompressProgressInfo, - public CMyUnknownImp -{ -public: - const UInt64 *InSize; - const UInt64 *OutSize; - HRESULT Result; - NWindows::NSynchronization::CAutoResetEvent ProgressEvent; - NWindows::NSynchronization::CAutoResetEvent WaitEvent; - - HRes Create() - { - RINOK(ProgressEvent.CreateIfNotCreated()); - return WaitEvent.CreateIfNotCreated(); - } - void Init() - { - ProgressEvent.Reset(); - WaitEvent.Reset(); - } - - MY_UNKNOWN_IMP - - STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); -}; - -#endif diff --git a/CPP/7zip/Archive/Common/HandlerOut.cpp b/CPP/7zip/Archive/Common/HandlerOut.cpp index 9c11b31d..95381ea3 100644 --- a/CPP/7zip/Archive/Common/HandlerOut.cpp +++ b/CPP/7zip/Archive/Common/HandlerOut.cpp @@ -147,7 +147,9 @@ HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PR #endif } else - return ParseMethodFromPROPVARIANT(names[i], value); + { + RINOK(ParseMethodFromPROPVARIANT(names[i], value)); + } } return S_OK; } diff --git a/CPP/7zip/Archive/Iso/IsoIn.cpp b/CPP/7zip/Archive/Iso/IsoIn.cpp index 1c7dd11e..1ebc15e8 100644 --- a/CPP/7zip/Archive/Iso/IsoIn.cpp +++ b/CPP/7zip/Archive/Iso/IsoIn.cpp @@ -294,7 +294,11 @@ void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d) d.FileStructureVersion = ReadByte(); // = 1 SkipZeros(1); ReadBytes(d.ApplicationUse, sizeof(d.ApplicationUse)); - SkipZeros(653); + + // Most ISO contains zeros in the following field (reserved for future standardization). + // But some ISO programs write some data to that area. + // So we disable check for zeros. + Skip(653); // SkipZeros(653); } static const Byte kSig_CD001[5] = { 'C', 'D', '0', '0', '1' }; diff --git a/CPP/7zip/Archive/Rar/Rar5Handler.cpp b/CPP/7zip/Archive/Rar/Rar5Handler.cpp index 2cfe805e..dff327f2 100644 --- a/CPP/7zip/Archive/Rar/Rar5Handler.cpp +++ b/CPP/7zip/Archive/Rar/Rar5Handler.cpp @@ -1292,6 +1292,18 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) break; } + case kpidError: + { + if (/* &_missingVol || */ !_missingVolName.IsEmpty()) + { + UString s; + s.SetFromAscii("Missing volume : "); + s += _missingVolName; + prop = s; + } + break; + } + case kpidErrorFlags: { UInt32 v = _errorFlags; @@ -1840,13 +1852,18 @@ HRESULT CHandler::Open2(IInStream *stream, break; } - HRESULT result = openVolumeCallback->GetStream(seqName.GetNextName(), &inStream); - if (result == S_FALSE) - break; - if (result != S_OK) + const UString volName = seqName.GetNextName(); + + HRESULT result = openVolumeCallback->GetStream(volName, &inStream); + + if (result != S_OK && result != S_FALSE) return result; - if (!inStream) + + if (!inStream || result != S_OK) + { + _missingVolName = volName; break; + } } UInt64 endPos = 0; @@ -2120,6 +2137,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream, STDMETHODIMP CHandler::Close() { COM_TRY_BEGIN + _missingVolName.Empty(); _errorFlags = 0; // _warningFlags = 0; _isArc = false; diff --git a/CPP/7zip/Archive/Rar/Rar5Handler.h b/CPP/7zip/Archive/Rar/Rar5Handler.h index 5eaf0075..cf741c7c 100644 --- a/CPP/7zip/Archive/Rar/Rar5Handler.h +++ b/CPP/7zip/Archive/Rar/Rar5Handler.h @@ -381,6 +381,7 @@ private: // UInt32 _warningFlags; bool _isArc; CByteBuffer _comment; + UString _missingVolName; DECL_EXTERNAL_CODECS_VARS diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp index dde15958..31c06d96 100644 --- a/CPP/7zip/Archive/Rar/RarHandler.cpp +++ b/CPP/7zip/Archive/Rar/RarHandler.cpp @@ -855,8 +855,21 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) break; } - // case kpidError: if (!_errorMessage.IsEmpty()) prop = _errorMessage; break; + case kpidError: + { + // if (!_errorMessage.IsEmpty()) prop = _errorMessage; break; + + if (/* &_missingVol || */ !_missingVolName.IsEmpty()) + { + UString s; + s.SetFromAscii("Missing volume : "); + s += _missingVolName; + prop = s; + } + break; + } + case kpidErrorFlags: { UInt32 v = _errorFlags; @@ -1050,14 +1063,18 @@ HRESULT CHandler::Open2(IInStream *stream, */ } - UString fullName = seqName.GetNextName(); - HRESULT result = openVolumeCallback->GetStream(fullName, &inStream); - if (result == S_FALSE) - break; - if (result != S_OK) + const UString volName = seqName.GetNextName(); + + HRESULT result = openVolumeCallback->GetStream(volName, &inStream); + + if (result != S_OK && result != S_FALSE) return result; - if (!inStream) + + if (!inStream || result != S_OK) + { + _missingVolName = volName; break; + } } else inStream = stream; @@ -1216,6 +1233,7 @@ STDMETHODIMP CHandler::Close() { COM_TRY_BEGIN // _errorMessage.Empty(); + _missingVolName.Empty(); _errorFlags = 0; _warningFlags = 0; _isArc = false; diff --git a/CPP/7zip/Archive/Rar/RarHandler.h b/CPP/7zip/Archive/Rar/RarHandler.h index dd3daa5d..9e6fb5cb 100644 --- a/CPP/7zip/Archive/Rar/RarHandler.h +++ b/CPP/7zip/Archive/Rar/RarHandler.h @@ -79,6 +79,7 @@ class CHandler: UInt32 _errorFlags; UInt32 _warningFlags; bool _isArc; + UString _missingVolName; DECL_EXTERNAL_CODECS_VARS diff --git a/CPP/7zip/Archive/VhdHandler.cpp b/CPP/7zip/Archive/VhdHandler.cpp index 0459571b..bddbf31b 100644 --- a/CPP/7zip/Archive/VhdHandler.cpp +++ b/CPP/7zip/Archive/VhdHandler.cpp @@ -682,9 +682,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) { s += " -> "; const CHandler *p = this; - while (p != 0 && p->NeedParent()) + while (p && p->NeedParent()) p = p->Parent; - if (p == 0) + if (!p) s += '?'; else s += p->Footer.GetTypeString(); @@ -750,26 +750,24 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) COM_TRY_END } + HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback *openArchiveCallback, unsigned level) { Close(); Stream = stream; if (level > (1 << 12)) // Maybe we need to increase that limit return S_FALSE; + RINOK(Open3()); + if (child && memcmp(child->Dyn.ParentId, Footer.Id, 16) != 0) return S_FALSE; if (Footer.Type != kDiskType_Diff) return S_OK; - CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback; - if (openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback) != S_OK) - { - // return S_FALSE; - } - CMyComPtr<IInStream> nextStream; bool useRelative; UString name; + if (!Dyn.RelativeParentNameFromLocator.IsEmpty()) { useRelative = true; @@ -780,11 +778,17 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback useRelative = false; name = Dyn.ParentName; } + Dyn.RelativeNameWasUsed = useRelative; + CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback; + openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback); + if (openVolumeCallback) { + CMyComPtr<IInStream> nextStream; HRESULT res = openVolumeCallback->GetStream(name, &nextStream); + if (res == S_FALSE) { if (useRelative && Dyn.ParentName != Dyn.RelativeParentNameFromLocator) @@ -793,19 +797,35 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback if (res == S_OK) Dyn.RelativeNameWasUsed = false; } - if (res == S_FALSE) - return S_OK; } - RINOK(res); + + if (res != S_OK && res != S_FALSE) + return res; + + if (res == S_FALSE || !nextStream) + { + UString s; + s.SetFromAscii("Missing volume : "); + s += name; + AddErrorMessage(s); + return S_OK; + } Parent = new CHandler; ParentStream = Parent; res = Parent->Open2(nextStream, this, openArchiveCallback, level + 1); - if (res == S_FALSE) + + if (res != S_OK) { Parent = NULL; ParentStream.Release(); + if (res == E_ABORT) + return res; + if (res != S_FALSE) + { + // we must show that error code + } } } { @@ -813,7 +833,7 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback while (p->NeedParent()) { p = p->Parent; - if (p == 0) + if (!p) { AddErrorMessage(L"Can't open parent VHD file:"); AddErrorMessage(Dyn.ParentName); @@ -824,12 +844,13 @@ HRESULT CHandler::Open2(IInStream *stream, CHandler *child, IArchiveOpenCallback return S_OK; } + void CHandler::CloseAtError() { _phySize = 0; Bat.Clear(); NumUsedBlocks = 0; - Parent = 0; + Parent = NULL; Stream.Release(); ParentStream.Release(); Dyn.Clear(); diff --git a/CPP/7zip/Archive/VmdkHandler.cpp b/CPP/7zip/Archive/VmdkHandler.cpp index 83e38d02..359691e3 100644 --- a/CPP/7zip/Archive/VmdkHandler.cpp +++ b/CPP/7zip/Archive/VmdkHandler.cpp @@ -450,6 +450,8 @@ class CHandler: public CHandlerImg CByteBuffer _descriptorBuf; CDescriptor _descriptor; + + UString _missingVolName; void InitAndSeekMain() { @@ -882,6 +884,19 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) case kpidNumVolumes: if (_isMultiVol) prop = (UInt32)_extents.Size(); break; + case kpidError: + { + if (_missingVol || !_missingVolName.IsEmpty()) + { + UString s; + s.SetFromAscii("Missing volume : "); + if (!_missingVolName.IsEmpty()) + s += _missingVolName; + prop = s; + } + break; + } + case kpidErrorFlags: { UInt32 v = 0; @@ -889,7 +904,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) if (_unsupported) v |= kpv_ErrorFlags_UnsupportedMethod; if (_unsupportedSome) v |= kpv_ErrorFlags_UnsupportedMethod; if (_headerError) v |= kpv_ErrorFlags_HeadersError; - if (_missingVol) v |= kpv_ErrorFlags_UnexpectedEnd; + // if (_missingVol) v |= kpv_ErrorFlags_UnexpectedEnd; if (v != 0) prop = v; break; @@ -1081,15 +1096,14 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *openCallback) } HRESULT result = volumeCallback->GetStream(u, &nextStream); - if (result == S_FALSE) - { - _missingVol = true; - continue; - } - if (result != S_OK) + + if (result != S_OK && result != S_FALSE) return result; - if (!nextStream) + + if (!nextStream || result != S_OK) { + if (_missingVolName.IsEmpty()) + _missingVolName = u; _missingVol = true; continue; } @@ -1431,6 +1445,8 @@ STDMETHODIMP CHandler::Close() _isMultiVol = false; _needDeflate = false; + _missingVolName.Empty(); + _descriptorBuf.Free(); _descriptor.Clear(); diff --git a/CPP/7zip/Archive/Wim/WimHandler.cpp b/CPP/7zip/Archive/Wim/WimHandler.cpp index 6c07f37c..910de06d 100644 --- a/CPP/7zip/Archive/Wim/WimHandler.cpp +++ b/CPP/7zip/Archive/Wim/WimHandler.cpp @@ -1028,6 +1028,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCal COM_TRY_END } + STDMETHODIMP CHandler::Close() { _firstVolumeIndex = -1; @@ -1093,7 +1094,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, CMyComPtr<ICompressProgressInfo> progress = lps; lps->Init(extractCallback, false); - for (i = 0; i < numItems; + for (i = 0;; i++, currentTotalUnPacked += currentItemUnPacked) { currentItemUnPacked = 0; @@ -1102,14 +1103,18 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, lps->OutSize = currentTotalUnPacked; RINOK(lps->SetCur()); + + if (i >= numItems) + break; + UInt32 index = allFilesMode ? i : indices[i]; - i++; Int32 askMode = testMode ? NExtract::NAskMode::kTest : NExtract::NAskMode::kExtract; CMyComPtr<ISequentialOutStream> realOutStream; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); + if (index >= _db.SortedItems.Size()) { if (!testMode && !realOutStream) @@ -1153,13 +1158,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, continue; RINOK(extractCallback->PrepareOperation(askMode)); Int32 opRes = NExtract::NOperationResult::kOK; + if (streamIndex != prevSuccessStreamIndex || realOutStream) { Byte digest[kHashSize]; const CVolume &vol = _volumes[si.PartNumber]; bool needDigest = !si.IsEmptyHash(); + HRESULT res = unpacker.Unpack(vol.Stream, si.Resource, vol.Header, &_db, realOutStream, progress, needDigest ? digest : NULL); + if (res == S_OK) { if (!needDigest || memcmp(digest, si.Hash, kHashSize) == 0) @@ -1174,13 +1182,16 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, else return res; } + realOutStream.Release(); RINOK(extractCallback->SetOperationResult(opRes)); } + return S_OK; COM_TRY_END } + STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) { *numItems = _db.SortedItems.Size() + diff --git a/CPP/7zip/Archive/Wim/WimIn.cpp b/CPP/7zip/Archive/Wim/WimIn.cpp index 1da6ca98..b1bed3c6 100644 --- a/CPP/7zip/Archive/Wim/WimIn.cpp +++ b/CPP/7zip/Archive/Wim/WimIn.cpp @@ -255,7 +255,12 @@ HRESULT CUnpacker::Unpack2( _solidIndex = resource.SolidIndex; _unpackedChunkIndex = chunkIndex; + + if (cur < offsetInChunk) + return E_FAIL; + cur -= offsetInChunk; + if (cur > rem) cur = (size_t)rem; diff --git a/CPP/7zip/Bundles/Alone/Alone.dsp b/CPP/7zip/Bundles/Alone/Alone.dsp index db2d54cd..b16ab914 100644 --- a/CPP/7zip/Bundles/Alone/Alone.dsp +++ b/CPP/7zip/Bundles/Alone/Alone.dsp @@ -554,14 +554,6 @@ SOURCE=..\..\Common\CreateCoder.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\Common\CrossThreadProgress.h -# End Source File -# Begin Source File - SOURCE=..\..\Common\CWrappers.cpp # End Source File # Begin Source File @@ -1285,14 +1277,6 @@ SOURCE=..\..\Archive\7z\7zFolderInStream.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\7z\7zFolderOutStream.h -# End Source File -# Begin Source File - SOURCE=..\..\Archive\7z\7zHandler.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/Bundles/Alone/makefile b/CPP/7zip/Bundles/Alone/makefile index 766bf96a..91ecfce4 100644 --- a/CPP/7zip/Bundles/Alone/makefile +++ b/CPP/7zip/Bundles/Alone/makefile @@ -77,7 +77,6 @@ AR_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\DummyOutStream.obj \ $O\FindSignature.obj \ $O\HandlerOut.obj \ @@ -94,7 +93,6 @@ AR_COMMON_OBJS = \ $O\7zEncode.obj \ $O\7zExtract.obj \ $O\7zFolderInStream.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zHandlerOut.obj \ $O\7zHeader.obj \ diff --git a/CPP/7zip/Bundles/Alone7z/Alone.dsp b/CPP/7zip/Bundles/Alone7z/Alone.dsp index 089e4020..d220b198 100644 --- a/CPP/7zip/Bundles/Alone7z/Alone.dsp +++ b/CPP/7zip/Bundles/Alone7z/Alone.dsp @@ -546,14 +546,6 @@ SOURCE=..\..\Common\CreateCoder.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\Common\CrossThreadProgress.h -# End Source File -# Begin Source File - SOURCE=..\..\Common\CWrappers.cpp # End Source File # Begin Source File @@ -812,14 +804,6 @@ SOURCE=..\..\Compress\LzmaEncoder.h SOURCE=..\..\Compress\LzmaRegister.cpp # End Source File -# Begin Source File - -SOURCE=..\..\Compress\RangeCoder.h -# End Source File -# Begin Source File - -SOURCE=..\..\Compress\RangeCoderBit.h -# End Source File # End Group # Begin Group "Archive" @@ -865,14 +849,6 @@ SOURCE=..\..\Archive\7z\7zFolderInStream.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\7z\7zFolderOutStream.h -# End Source File -# Begin Source File - SOURCE=..\..\Archive\7z\7zHandler.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/Bundles/Alone7z/makefile b/CPP/7zip/Bundles/Alone7z/makefile index 7589bc30..15c51f91 100644 --- a/CPP/7zip/Bundles/Alone7z/makefile +++ b/CPP/7zip/Bundles/Alone7z/makefile @@ -67,7 +67,6 @@ AR_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\DummyOutStream.obj \ $O\HandlerOut.obj \ $O\InStreamWithCRC.obj \ @@ -83,7 +82,6 @@ AR_COMMON_OBJS = \ $O\7zEncode.obj \ $O\7zExtract.obj \ $O\7zFolderInStream.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zHandlerOut.obj \ $O\7zHeader.obj \ diff --git a/CPP/7zip/Bundles/Fm/FM.dsp b/CPP/7zip/Bundles/Fm/FM.dsp index 057da977..eb1aa103 100644 --- a/CPP/7zip/Bundles/Fm/FM.dsp +++ b/CPP/7zip/Bundles/Fm/FM.dsp @@ -211,196 +211,188 @@ SOURCE=..\..\UI\FileManager\Test.bmp # Begin Group "Archive" # PROP Default_Filter "" -# Begin Group "7z" +# Begin Group "Archive Common" # PROP Default_Filter "" # Begin Source File -SOURCE=..\..\Archive\7z\7zCompressionMode.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\7z\7zCompressionMode.h +SOURCE=..\..\Archive\Common\CoderMixer2.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zDecode.cpp +SOURCE=..\..\Archive\Common\CoderMixer2.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zDecode.h +SOURCE=..\..\Archive\Common\DummyOutStream.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zEncode.cpp +SOURCE=..\..\Archive\Common\DummyOutStream.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zEncode.h +SOURCE=..\..\Archive\Common\FindSignature.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zExtract.cpp +SOURCE=..\..\Archive\Common\FindSignature.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zFolderInStream.cpp +SOURCE=..\..\Archive\Common\HandlerOut.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zFolderInStream.h +SOURCE=..\..\Archive\Common\HandlerOut.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp +SOURCE=..\..\Archive\Common\InStreamWithCRC.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zFolderOutStream.h +SOURCE=..\..\Archive\Common\InStreamWithCRC.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zHandler.cpp +SOURCE=..\..\Archive\Common\ItemNameUtils.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zHandler.h +SOURCE=..\..\Archive\Common\ItemNameUtils.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zHandlerOut.cpp +SOURCE=..\..\Archive\Common\MultiStream.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zHeader.cpp +SOURCE=..\..\Archive\Common\MultiStream.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zHeader.h +SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zIn.cpp +SOURCE=..\..\Archive\Common\OutStreamWithCRC.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zIn.h +SOURCE=..\..\Archive\Common\ParseProperties.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zItem.h +SOURCE=..\..\Archive\Common\ParseProperties.h # End Source File -# Begin Source File +# End Group +# Begin Group "7z" -SOURCE=..\..\Archive\7z\7zOut.cpp -# End Source File +# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\Archive\7z\7zOut.h +SOURCE=..\..\Archive\7z\7zCompressionMode.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zProperties.cpp +SOURCE=..\..\Archive\7z\7zCompressionMode.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zProperties.h +SOURCE=..\..\Archive\7z\7zDecode.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zRegister.cpp +SOURCE=..\..\Archive\7z\7zDecode.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zSpecStream.cpp +SOURCE=..\..\Archive\7z\7zEncode.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zSpecStream.h +SOURCE=..\..\Archive\7z\7zEncode.h # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zUpdate.cpp +SOURCE=..\..\Archive\7z\7zExtract.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zUpdate.h +SOURCE=..\..\Archive\7z\7zFolderInStream.cpp # End Source File -# End Group -# Begin Group "Archive Common" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\Archive\Common\CoderMixer2.cpp +SOURCE=..\..\Archive\7z\7zFolderInStream.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\CoderMixer2.h +SOURCE=..\..\Archive\7z\7zHandler.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\DummyOutStream.cpp +SOURCE=..\..\Archive\7z\7zHandler.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\DummyOutStream.h +SOURCE=..\..\Archive\7z\7zHandlerOut.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\FindSignature.cpp +SOURCE=..\..\Archive\7z\7zHeader.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\FindSignature.h +SOURCE=..\..\Archive\7z\7zHeader.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\HandlerOut.cpp +SOURCE=..\..\Archive\7z\7zIn.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\HandlerOut.h +SOURCE=..\..\Archive\7z\7zIn.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\InStreamWithCRC.cpp +SOURCE=..\..\Archive\7z\7zItem.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\InStreamWithCRC.h +SOURCE=..\..\Archive\7z\7zOut.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\ItemNameUtils.cpp +SOURCE=..\..\Archive\7z\7zOut.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\ItemNameUtils.h +SOURCE=..\..\Archive\7z\7zProperties.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\MultiStream.cpp +SOURCE=..\..\Archive\7z\7zProperties.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\MultiStream.h +SOURCE=..\..\Archive\7z\7zRegister.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp +SOURCE=..\..\Archive\7z\7zSpecStream.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\OutStreamWithCRC.h +SOURCE=..\..\Archive\7z\7zSpecStream.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\ParseProperties.cpp +SOURCE=..\..\Archive\7z\7zUpdate.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\ParseProperties.h +SOURCE=..\..\Archive\7z\7zUpdate.h # End Source File # End Group # Begin Source File diff --git a/CPP/7zip/Bundles/Format7z/makefile b/CPP/7zip/Bundles/Format7z/makefile index 992fc714..1fb1d451 100644 --- a/CPP/7zip/Bundles/Format7z/makefile +++ b/CPP/7zip/Bundles/Format7z/makefile @@ -49,7 +49,6 @@ AR_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\HandlerOut.obj \ $O\InStreamWithCRC.obj \ $O\ItemNameUtils.obj \ @@ -63,7 +62,6 @@ AR_COMMON_OBJS = \ $O\7zEncode.obj \ $O\7zExtract.obj \ $O\7zFolderInStream.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zHandlerOut.obj \ $O\7zHeader.obj \ diff --git a/CPP/7zip/Bundles/Format7zExtract/makefile b/CPP/7zip/Bundles/Format7zExtract/makefile index 93240c80..b512144d 100644 --- a/CPP/7zip/Bundles/Format7zExtract/makefile +++ b/CPP/7zip/Bundles/Format7zExtract/makefile @@ -7,12 +7,12 @@ COMMON_OBJS = \ $O\CRC.obj \ $O\CrcReg.obj \ $O\IntToString.obj \ - $O\NewHandler.obj \ $O\MyString.obj \ + $O\MyVector.obj \ + $O\NewHandler.obj \ $O\Sha256Reg.obj \ $O\StringConvert.obj \ $O\StringToInt.obj \ - $O\MyVector.obj \ $O\Wildcard.obj \ WIN_OBJS = \ @@ -42,7 +42,6 @@ AR_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\ItemNameUtils.obj \ $O\OutStreamWithCRC.obj \ $O\ParseProperties.obj \ @@ -51,7 +50,6 @@ AR_COMMON_OBJS = \ $O\7zCompressionMode.obj \ $O\7zDecode.obj \ $O\7zExtract.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zHeader.obj \ $O\7zIn.obj \ diff --git a/CPP/7zip/Bundles/Format7zExtractR/makefile b/CPP/7zip/Bundles/Format7zExtractR/makefile index 3d49c46f..724477e9 100644 --- a/CPP/7zip/Bundles/Format7zExtractR/makefile +++ b/CPP/7zip/Bundles/Format7zExtractR/makefile @@ -42,7 +42,6 @@ AR_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\HandlerOut.obj \ $O\ItemNameUtils.obj \ $O\OutStreamWithCRC.obj \ @@ -53,7 +52,6 @@ AR_COMMON_OBJS = \ $O\7zCompressionMode.obj \ $O\7zDecode.obj \ $O\7zExtract.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zHeader.obj \ $O\7zIn.obj \ diff --git a/CPP/7zip/Bundles/Format7zF/Arc.mak b/CPP/7zip/Bundles/Format7zF/Arc.mak index d4002e9b..44bd023b 100644 --- a/CPP/7zip/Bundles/Format7zF/Arc.mak +++ b/CPP/7zip/Bundles/Format7zF/Arc.mak @@ -93,7 +93,6 @@ AR_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\DummyOutStream.obj \ $O\FindSignature.obj \ $O\InStreamWithCRC.obj \ @@ -111,7 +110,6 @@ AR_COMMON_OBJS = \ $O\7zEncode.obj \ $O\7zExtract.obj \ $O\7zFolderInStream.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zHandlerOut.obj \ $O\7zHeader.obj \ diff --git a/CPP/7zip/Bundles/Format7zR/makefile b/CPP/7zip/Bundles/Format7zR/makefile index 8d41ce89..916dc568 100644 --- a/CPP/7zip/Bundles/Format7zR/makefile +++ b/CPP/7zip/Bundles/Format7zR/makefile @@ -47,7 +47,6 @@ AR_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\HandlerOut.obj \ $O\InStreamWithCRC.obj \ $O\ItemNameUtils.obj \ @@ -61,7 +60,6 @@ AR_COMMON_OBJS = \ $O\7zEncode.obj \ $O\7zExtract.obj \ $O\7zFolderInStream.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zHandlerOut.obj \ $O\7zHeader.obj \ diff --git a/CPP/7zip/Bundles/SFXCon/SFXCon.dsp b/CPP/7zip/Bundles/SFXCon/SFXCon.dsp index 0cacd60c..4f55d013 100644 --- a/CPP/7zip/Bundles/SFXCon/SFXCon.dsp +++ b/CPP/7zip/Bundles/SFXCon/SFXCon.dsp @@ -117,14 +117,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\Common\CrossThreadProgress.h -# End Source File -# Begin Source File - SOURCE=..\..\Archive\Common\ItemNameUtils.cpp # End Source File # Begin Source File @@ -221,14 +213,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\7z\7zFolderOutStream.h -# End Source File -# Begin Source File - SOURCE=..\..\Archive\7z\7zHandler.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/Bundles/SFXCon/makefile b/CPP/7zip/Bundles/SFXCon/makefile index d3d61372..f1cd2f57 100644 --- a/CPP/7zip/Bundles/SFXCon/makefile +++ b/CPP/7zip/Bundles/SFXCon/makefile @@ -72,7 +72,6 @@ AR_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\ItemNameUtils.obj \ $O\MultiStream.obj \ $O\OutStreamWithCRC.obj \ @@ -81,7 +80,6 @@ AR_COMMON_OBJS = \ 7Z_OBJS = \ $O\7zDecode.obj \ $O\7zExtract.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zIn.obj \ $O\7zRegister.obj \ diff --git a/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp index 1f076f7d..f2783e02 100644 --- a/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp +++ b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp @@ -157,14 +157,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\7z\7zFolderOutStream.h -# End Source File -# Begin Source File - SOURCE=..\..\Archive\7z\7zHandler.cpp # End Source File # Begin Source File @@ -205,14 +197,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\Common\CrossThreadProgress.h -# End Source File -# Begin Source File - SOURCE=..\..\Archive\Common\ItemNameUtils.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/Bundles/SFXSetup/makefile b/CPP/7zip/Bundles/SFXSetup/makefile index ae631988..5f6f6032 100644 --- a/CPP/7zip/Bundles/SFXSetup/makefile +++ b/CPP/7zip/Bundles/SFXSetup/makefile @@ -67,14 +67,12 @@ FM_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\ItemNameUtils.obj \ $O\OutStreamWithCRC.obj \ 7Z_OBJS = \ $O\7zDecode.obj \ $O\7zExtract.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zIn.obj \ $O\7zRegister.obj \ diff --git a/CPP/7zip/Bundles/SFXWin/SFXWin.dsp b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp index 3e11881b..944feb4d 100644 --- a/CPP/7zip/Bundles/SFXWin/SFXWin.dsp +++ b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp @@ -149,14 +149,6 @@ SOURCE=..\..\Archive\7z\7zExtract.cpp # End Source File # Begin Source File -SOURCE=..\..\Archive\7z\7zFolderOutStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\7z\7zFolderOutStream.h -# End Source File -# Begin Source File - SOURCE=..\..\Archive\7z\7zHandler.cpp # End Source File # Begin Source File @@ -197,14 +189,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2.h # End Source File # Begin Source File -SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\Common\CrossThreadProgress.h -# End Source File -# Begin Source File - SOURCE=..\..\Archive\Common\ItemNameUtils.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/Bundles/SFXWin/makefile b/CPP/7zip/Bundles/SFXWin/makefile index 7f2a78c1..0ffec922 100644 --- a/CPP/7zip/Bundles/SFXWin/makefile +++ b/CPP/7zip/Bundles/SFXWin/makefile @@ -92,7 +92,6 @@ AR_OBJS = \ AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ - $O\CrossThreadProgress.obj \ $O\ItemNameUtils.obj \ $O\MultiStream.obj \ $O\OutStreamWithCRC.obj \ @@ -100,7 +99,6 @@ AR_COMMON_OBJS = \ 7Z_OBJS = \ $O\7zDecode.obj \ $O\7zExtract.obj \ - $O\7zFolderOutStream.obj \ $O\7zHandler.obj \ $O\7zIn.obj \ $O\7zRegister.obj \ diff --git a/CPP/7zip/UI/Client7z/Client7z.cpp b/CPP/7zip/UI/Client7z/Client7z.cpp index c6522fe7..55650cfa 100644 --- a/CPP/7zip/UI/Client7z/Client7z.cpp +++ b/CPP/7zip/UI/Client7z/Client7z.cpp @@ -693,7 +693,7 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef return StringToBstr(Password, password); } -////////////////////////////////////////////////////////////////////////// + // Main function #define NT_CHECK_FAIL_ACTION PrintError("Unsupported Windows version"); return 1; @@ -709,12 +709,14 @@ int MY_CDECL main(int numArgs, const char *args[]) PrintStringLn(kHelpString); return 1; } + NDLL::CLibrary lib; if (!lib.Load(NDLL::GetModuleDirPrefix() + FTEXT(kDllName))) { PrintError("Can not load 7-zip library"); return 1; } + Func_CreateObject createObjectFunc = (Func_CreateObject)lib.GetProc("CreateObject"); if (!createObjectFunc) { @@ -732,7 +734,9 @@ int MY_CDECL main(int numArgs, const char *args[]) } c = (char)MyCharLower_Ascii(command[0]); } + FString archiveName = CmdStringToFString(args[2]); + if (c == 'a') { // create archive command @@ -766,6 +770,7 @@ int MY_CDECL main(int numArgs, const char *args[]) dirItems.Add(di); } } + COutFileStream *outFileStreamSpec = new COutFileStream; CMyComPtr<IOutStream> outFileStream = outFileStreamSpec; if (!outFileStreamSpec->Create(archiveName, false)) @@ -812,17 +817,21 @@ int MY_CDECL main(int numArgs, const char *args[]) */ HRESULT result = outArchive->UpdateItems(outFileStream, dirItems.Size(), updateCallback); + updateCallbackSpec->Finilize(); + if (result != S_OK) { PrintError("Update Error"); return 1; } + FOR_VECTOR (i, updateCallbackSpec->FailedFiles) { PrintNewLine(); PrintError("Error for file", updateCallbackSpec->FailedFiles[i]); } + if (updateCallbackSpec->FailedFiles.Size() != 0) return 1; } @@ -835,6 +844,7 @@ int MY_CDECL main(int numArgs, const char *args[]) } bool listCommand; + if (c == 'l') listCommand = true; else if (c == 'x') @@ -913,7 +923,27 @@ int MY_CDECL main(int numArgs, const char *args[]) extractCallbackSpec->PasswordIsDefined = false; // extractCallbackSpec->PasswordIsDefined = true; // extractCallbackSpec->Password = L"1"; + + /* + const wchar_t *names[] = + { + L"mt", + L"mtf" + }; + const unsigned kNumProps = sizeof(names) / sizeof(names[0]); + NCOM::CPropVariant values[kNumProps] = + { + (UInt32)1, + false + }; + CMyComPtr<ISetProperties> setProperties; + archive->QueryInterface(IID_ISetProperties, (void **)&setProperties); + if (setProperties) + setProperties->SetProperties(names, values, kNumProps); + */ + HRESULT result = archive->Extract(NULL, (UInt32)(Int32)(-1), false, extractCallback); + if (result != S_OK) { PrintError("Extract Error"); @@ -921,5 +951,6 @@ int MY_CDECL main(int numArgs, const char *args[]) } } } + return 0; } diff --git a/CPP/7zip/UI/Common/Bench.cpp b/CPP/7zip/UI/Common/Bench.cpp index 5f6373f4..3833f07f 100644 --- a/CPP/7zip/UI/Common/Bench.cpp +++ b/CPP/7zip/UI/Common/Bench.cpp @@ -2,6 +2,8 @@ #include "StdAfx.h" +#include <stdio.h> + #ifndef _WIN32 #define USE_POSIX_TIME #define USE_POSIX_TIME2 @@ -39,6 +41,15 @@ #include "../../../Windows/Thread.h" #endif +#if defined(_WIN32) || defined(UNIX_USE_WIN_FILE) +#define USE_WIN_FILE +#endif + +#ifdef USE_WIN_FILE +#include "../../../Windows/FileIO.h" +#endif + + #include "../../../Common/IntToString.h" #include "../../../Common/StringConvert.h" #include "../../../Common/StringToInt.h" @@ -50,6 +61,8 @@ using namespace NWindows; +static const UInt32 k_LZMA = 0x030101; + static const UInt64 kComplexInCommands = (UInt64)1 << #ifdef UNDER_CE 31; @@ -57,15 +70,17 @@ static const UInt64 kComplexInCommands = (UInt64)1 << 34; #endif -static const UInt64 kComplexInSeconds = 4; +static const UInt32 kComplexInSeconds = 4; -static void SetComplexCommands(UInt32 complexInSeconds, UInt64 cpuFreq, UInt64 &complexInCommands) +static void SetComplexCommands(UInt32 complexInSeconds, + bool isSpecifiedFreq, UInt64 cpuFreq, UInt64 &complexInCommands) { complexInCommands = kComplexInCommands; - const UInt64 kMinFreq = (UInt64)1000000 * 30; + const UInt64 kMinFreq = (UInt64)1000000 * 4; const UInt64 kMaxFreq = (UInt64)1000000 * 20000; - if (cpuFreq < kMinFreq) cpuFreq = kMinFreq; - if (cpuFreq < kMaxFreq) + if (cpuFreq < kMinFreq && !isSpecifiedFreq) + cpuFreq = kMinFreq; + if (cpuFreq < kMaxFreq || isSpecifiedFreq) { if (complexInSeconds != 0) complexInCommands = complexInSeconds * cpuFreq; @@ -98,87 +113,154 @@ public: } }; -class CBenchBuffer + +static const unsigned kBufferAlignment = 1 << 4; + +struct CBenchBuffer { -public: size_t BufferSize; + + #ifdef _WIN32 + Byte *Buffer; - CBenchBuffer(): Buffer(0) {} - virtual ~CBenchBuffer() { Free(); } - void Free() + CBenchBuffer(): BufferSize(0), Buffer(NULL) {} + ~CBenchBuffer() { ::MidFree(Buffer); } + + void AllocAlignedMask(size_t size, size_t) { ::MidFree(Buffer); - Buffer = 0; + BufferSize = 0; + Buffer = (Byte *)::MidAlloc(size); + if (Buffer) + BufferSize = size; + } + + #else + + Byte *Buffer; + Byte *_bufBase; + + CBenchBuffer(): BufferSize(0), Buffer(NULL), _bufBase(NULL){} + ~CBenchBuffer() { ::MidFree(_bufBase); } + + void AllocAlignedMask(size_t size, size_t alignMask) + { + ::MidFree(_bufBase); + Buffer = NULL; + BufferSize = 0; + _bufBase = (Byte *)::MidAlloc(size + alignMask); + + if (_bufBase) + { + // Buffer = (Byte *)(((uintptr_t)_bufBase + alignMask) & ~(uintptr_t)alignMask); + Buffer = (Byte *)(((ptrdiff_t)_bufBase + alignMask) & ~(ptrdiff_t)alignMask); + BufferSize = size; + } } - bool Alloc(size_t bufferSize) + + #endif + + bool Alloc(size_t size) { - if (Buffer != 0 && BufferSize == bufferSize) + if (Buffer && BufferSize == size) return true; - Free(); - Buffer = (Byte *)::MidAlloc(bufferSize); - BufferSize = bufferSize; - return (Buffer != 0 || bufferSize == 0); + AllocAlignedMask(size, kBufferAlignment - 1); + return (Buffer != NULL || size == 0); } }; + class CBenchRandomGenerator: public CBenchBuffer { - CBaseRandomGenerator *RG; -public: - void Set(CBaseRandomGenerator *rg) { RG = rg; } - UInt32 GetVal(UInt32 &res, unsigned numBits) + static UInt32 GetVal(UInt32 &res, unsigned numBits) { UInt32 val = res & (((UInt32)1 << numBits) - 1); res >>= numBits; return val; } - UInt32 GetLen(UInt32 &res) + + static UInt32 GetLen(UInt32 &r) { - UInt32 len = GetVal(res, 2); - return GetVal(res, 1 + len); + UInt32 len = GetVal(r, 2); + return GetVal(r, 1 + len); } - void GenerateSimpleRandom() +public: + + void GenerateSimpleRandom(CBaseRandomGenerator *_RG_) { - for (UInt32 i = 0; i < BufferSize; i++) - Buffer[i] = (Byte)RG->GetRnd(); + CBaseRandomGenerator rg = *_RG_; + const size_t bufSize = BufferSize; + Byte *buf = Buffer; + for (size_t i = 0; i < bufSize; i++) + buf[i] = (Byte)rg.GetRnd(); + *_RG_ = rg; } - void Generate(unsigned dictBits) + void GenerateLz(unsigned dictBits, CBaseRandomGenerator *_RG_) { + CBaseRandomGenerator rg = *_RG_; UInt32 pos = 0; UInt32 rep0 = 1; - while (pos < BufferSize) + const size_t bufSize = BufferSize; + Byte *buf = Buffer; + unsigned posBits = 1; + + while (pos < bufSize) { - UInt32 res = RG->GetRnd(); - res >>= 1; - if (GetVal(res, 1) == 0 || pos < 1024) - Buffer[pos++] = (Byte)(res & 0xFF); + UInt32 r = rg.GetRnd(); + if (GetVal(r, 1) == 0 || pos < 1024) + buf[pos++] = (Byte)(r & 0xFF); else { UInt32 len; - len = 1 + GetLen(res); - if (GetVal(res, 3) != 0) + len = 1 + GetLen(r); + + if (GetVal(r, 3) != 0) { - len += GetLen(res); - do + len += GetLen(r); + + while (((UInt32)1 << posBits) < pos) + posBits++; + + unsigned numBitsMax = dictBits; + if (numBitsMax > posBits) + numBitsMax = posBits; + + const unsigned kAddBits = 6; + unsigned numLogBits = 5; + if (numBitsMax <= (1 << 4) - 1 + kAddBits) + numLogBits = 4; + + for (;;) { - UInt32 ppp = GetVal(res, 5) + 6; - res = RG->GetRnd(); - if (ppp > dictBits) + UInt32 ppp = GetVal(r, numLogBits) + kAddBits; + r = rg.GetRnd(); + if (ppp > numBitsMax) continue; - rep0 = /* (1 << ppp) +*/ GetVal(res, ppp); - res = RG->GetRnd(); + rep0 = GetVal(r, ppp); + if (rep0 < pos) + break; + r = rg.GetRnd(); } - while (rep0 >= pos); rep0++; } - for (UInt32 i = 0; i < len && pos < BufferSize; i++, pos++) - Buffer[pos] = Buffer[pos - rep0]; + { + UInt32 rem = (UInt32)bufSize - pos; + if (len > rem) + len = rem; + } + Byte *dest = buf + pos; + const Byte *src = dest - rep0; + pos += len; + for (UInt32 i = 0; i < len; i++) + *dest++ = *src++; } } + + *_RG_ = rg; } }; @@ -238,6 +320,9 @@ public: // _overflow = false; Pos = 0; } + + // void Print() { printf("\n%8d %8d\n", (unsigned)BufferSize, (unsigned)Pos); } + MY_UNKNOWN_IMP STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); }; @@ -475,11 +560,11 @@ STDMETHODIMP CBenchProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 return res; } -static const int kSubBits = 8; +static const unsigned kSubBits = 8; static UInt32 GetLogSize(UInt32 size) { - for (int i = kSubBits; i < 32; i++) + for (unsigned i = kSubBits; i < 32; i++) for (UInt32 j = 0; j < (1 << kSubBits); j++) if (size <= (((UInt32)1) << i) + (j << (i - kSubBits))) return (i << kSubBits) + j; @@ -651,26 +736,30 @@ struct CEncoderInfo IBenchCallback *callback; IBenchPrintCallback *printCallback; UInt32 crc; - UInt32 kBufferSize; + size_t kBufferSize; size_t compressedSize; + const Byte *uncompressedDataPtr; + + const Byte *fileData; CBenchRandomGenerator rg; + CBenchBuffer rgCopy; // it must be 16-byte aligned !!! CBenchmarkOutStream *propStreamSpec; CMyComPtr<ISequentialOutStream> propStream; // for decode COneMethodInfo _method; - UInt32 _uncompressedDataSize; + size_t _uncompressedDataSize; HRESULT Init( const COneMethodInfo &method, - UInt32 uncompressedDataSize, unsigned generateDictBits, CBaseRandomGenerator *rg); HRESULT Encode(); HRESULT Decode(UInt32 decoderIndex); CEncoderInfo(): + fileData(NULL), CheckCrc_Enc(true), CheckCrc_Dec(true), outStreamSpec(0), callback(0), printCallback(0), propStreamSpec(0) {} @@ -738,30 +827,42 @@ struct CEncoderInfo #endif }; -static const UInt32 k_LZMA = 0x030101; HRESULT CEncoderInfo::Init( const COneMethodInfo &method, - UInt32 uncompressedDataSize, unsigned generateDictBits, CBaseRandomGenerator *rgLoc) { - rg.Set(rgLoc); - kBufferSize = uncompressedDataSize; - UInt32 kCompressedBufferSize = - kBufferSize + kCompressedAdditionalSize; - // (kBufferSize - kBufferSize / 4) + kCompressedAdditionalSize; - if (!rg.Alloc(kBufferSize)) - return E_OUTOFMEMORY; - if (generateDictBits == 0) - rg.GenerateSimpleRandom(); - else - rg.Generate(generateDictBits); - crc = CrcCalc(rg.Buffer, rg.BufferSize); + // we need extra space, if input data is already compressed + const size_t kCompressedBufferSize = + kCompressedAdditionalSize + + kBufferSize + kBufferSize / 16; + // kBufferSize / 2; + if (kCompressedBufferSize < kBufferSize) + return E_FAIL; + + uncompressedDataPtr = fileData; + + if (!fileData) + { + if (!rg.Alloc(kBufferSize)) + return E_OUTOFMEMORY; + + // DWORD ttt = GetTickCount(); + if (generateDictBits == 0) + rg.GenerateSimpleRandom(rgLoc); + else + rg.GenerateLz(generateDictBits, rgLoc); + // printf("\n%d\n ", GetTickCount() - ttt); + + crc = CrcCalc(rg.Buffer, rg.BufferSize); + uncompressedDataPtr = rg.Buffer; + } + if (_encoderFilter) { - if (!rgCopy.Alloc(rg.BufferSize)) + if (!rgCopy.Alloc(kBufferSize)) return E_OUTOFMEMORY; } @@ -793,7 +894,7 @@ HRESULT CEncoderInfo::Init( coder.QueryInterface(IID_ICompressSetCoderProperties, &scp); if (scp) { - UInt64 reduceSize = uncompressedDataSize; + UInt64 reduceSize = kBufferSize; RINOK(method.SetCoderProps(scp, &reduceSize)); } else @@ -839,11 +940,30 @@ HRESULT CEncoderInfo::Init( } } } - } + return S_OK; } + +static void My_FilterBench(ICompressFilter *filter, Byte *data, size_t size) +{ + while (size != 0) + { + UInt32 cur = (UInt32)1 << 31; + if (cur > size) + cur = (UInt32)size; + UInt32 processed = filter->Filter(data, cur); + data += processed; + // if (processed > size) (in AES filter), we must fill last block with zeros. + // but it is not important for benchmark. So we just copy that data without filtering. + if (processed > size || processed == 0) + break; + size -= processed; + } +} + + HRESULT CEncoderInfo::Encode() { CBenchInfo &bi = progressInfoSpec[0]->BenchInfo; @@ -882,31 +1002,36 @@ HRESULT CEncoderInfo::Encode() if (_encoderFilter) { - memcpy(rgCopy.Buffer, rg.Buffer, rg.BufferSize); + memcpy(rgCopy.Buffer, uncompressedDataPtr, kBufferSize); _encoderFilter->Init(); - _encoderFilter->Filter(rgCopy.Buffer, (UInt32)rg.BufferSize); - RINOK(WriteStream(outStream, rgCopy.Buffer, rg.BufferSize)); + My_FilterBench(_encoderFilter, rgCopy.Buffer, kBufferSize); + RINOK(WriteStream(outStream, rgCopy.Buffer, kBufferSize)); } else { - inStreamSpec->Init(rg.Buffer, rg.BufferSize); - RINOK(_encoder->Code(inStream, outStream, 0, 0, progressInfo[0])); + inStreamSpec->Init(uncompressedDataPtr, kBufferSize); + RINOK(_encoder->Code(inStream, outStream, NULL, NULL, progressInfo[0])); } + // outStreamSpec->Print(); + UInt32 crcNew = CRC_GET_DIGEST(outStreamSpec->Crc); if (i == 0) crcPrev = crcNew; else if (calcCrc && crcPrev != crcNew) return E_FAIL; + compressedSize = outStreamSpec->Pos; - bi.UnpackSize += rg.BufferSize; + bi.UnpackSize += kBufferSize; bi.PackSize += compressedSize; } + _encoder.Release(); _encoderFilter.Release(); return S_OK; } + HRESULT CEncoderInfo::Decode(UInt32 decoderIndex) { CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream; @@ -991,29 +1116,33 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex) UInt64 outSize = kBufferSize; crcOutStreamSpec->CalcCrc = ((i & 0x7F) == 0 || CheckCrc_Dec); + if (_decoderFilter) { if (compressedSize > rgCopy.BufferSize) return E_FAIL; memcpy(rgCopy.Buffer, outStreamSpec->Buffer, compressedSize); _decoderFilter->Init(); - _decoderFilter->Filter(rgCopy.Buffer, (UInt32)compressedSize); - RINOK(WriteStream(crcOutStream, rgCopy.Buffer, rg.BufferSize)); + My_FilterBench(_decoderFilter, rgCopy.Buffer, compressedSize); + RINOK(WriteStream(crcOutStream, rgCopy.Buffer, compressedSize)); } else { RINOK(decoder->Code(inStream, crcOutStream, 0, &outSize, progressInfo[decoderIndex])); } + if (crcOutStreamSpec->CalcCrc && CRC_GET_DIGEST(crcOutStreamSpec->Crc) != crc) return S_FALSE; pi->BenchInfo.UnpackSize += kBufferSize; pi->BenchInfo.PackSize += compressedSize; } + decoder.Release(); _decoderFilter.Release(); return S_OK; } + static const UInt32 kNumThreadsMax = (1 << 12); struct CBenchEncoders @@ -1023,6 +1152,7 @@ struct CBenchEncoders ~CBenchEncoders() { delete []encoders; } }; + static UInt64 GetNumIterations(UInt64 numCommands, UInt64 complexInCommands) { if (numCommands < (1 << 4)) @@ -1031,6 +1161,7 @@ static UInt64 GetNumIterations(UInt64 numCommands, UInt64 complexInCommands) return (res == 0 ? 1 : res); } + static HRESULT MethodBench( DECL_EXTERNAL_CODECS_LOC_VARS UInt64 complexInCommands, @@ -1045,7 +1176,8 @@ static HRESULT MethodBench( #endif , const COneMethodInfo &method2, - UInt32 uncompressedDataSize, + size_t uncompressedDataSize, + const Byte *fileData, unsigned generateDictBits, IBenchPrintCallback *printCallback, @@ -1086,6 +1218,7 @@ static HRESULT MethodBench( CEncoderInfo *encoders = encodersSpec.encoders; UInt32 i; + for (i = 0; i < numEncoderThreads; i++) { CEncoderInfo &encoder = encoders[i]; @@ -1120,12 +1253,21 @@ static HRESULT MethodBench( CBaseRandomGenerator rg; rg.Init(); + + UInt32 crc = 0; + if (fileData) + crc = CrcCalc(fileData, uncompressedDataSize); + for (i = 0; i < numEncoderThreads; i++) { CEncoderInfo &encoder = encoders[i]; encoder._method = method; encoder._uncompressedDataSize = uncompressedDataSize; - RINOK(encoders[i].Init(method, uncompressedDataSize, generateDictBits, &rg)); + encoder.kBufferSize = uncompressedDataSize; + encoder.fileData = fileData; + encoder.crc = crc; + + RINOK(encoders[i].Init(method, generateDictBits, &rg)); } CBenchProgressStatus status; @@ -1144,6 +1286,7 @@ static HRESULT MethodBench( encoder.progressInfo[j] = spec; spec->Status = &status; } + if (i == 0) { CBenchProgressInfo *bpi = encoder.progressInfoSpec[0]; @@ -1167,6 +1310,7 @@ static HRESULT MethodBench( RINOK(encoder.Encode()); } } + #ifndef _7ZIP_ST if (numEncoderThreads > 1) for (i = 0; i < numEncoderThreads; i++) @@ -1181,12 +1325,14 @@ static HRESULT MethodBench( info.UnpackSize = 0; info.PackSize = 0; info.NumIterations = encoders[0].NumIterations; + for (i = 0; i < numEncoderThreads; i++) { CEncoderInfo &encoder = encoders[i]; info.UnpackSize += encoder.kBufferSize; info.PackSize += encoder.compressedSize; } + RINOK(callback->SetEncodeResult(info, true)); @@ -1194,6 +1340,7 @@ static HRESULT MethodBench( status.EncodeMode = false; UInt32 numDecoderThreads = numEncoderThreads * numSubDecoderThreads; + for (i = 0; i < numEncoderThreads; i++) { CEncoderInfo &encoder = encoders[i]; @@ -1266,12 +1413,14 @@ static HRESULT MethodBench( info.UnpackSize = 0; info.PackSize = 0; info.NumIterations = numSubDecoderThreads * encoders[0].NumIterations; + for (i = 0; i < numEncoderThreads; i++) { CEncoderInfo &encoder = encoders[i]; info.UnpackSize += encoder.kBufferSize; info.PackSize += encoder.compressedSize; } + RINOK(callback->SetDecodeResult(info, false)); RINOK(callback->SetDecodeResult(info, true)); @@ -1279,7 +1428,7 @@ static HRESULT MethodBench( } -inline UInt64 GetLZMAUsage(bool multiThread, UInt32 dictionary) +static inline UInt64 GetLZMAUsage(bool multiThread, UInt32 dictionary) { UInt32 hs = dictionary - 1; hs |= (hs >> 1); @@ -1295,14 +1444,16 @@ inline UInt64 GetLZMAUsage(bool multiThread, UInt32 dictionary) (1 << 20) + (multiThread ? (6 << 20) : 0); } -UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary) +UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary, bool totalBench) { const UInt32 kBufferSize = dictionary; - const UInt32 kCompressedBufferSize = (kBufferSize / 2); - UInt32 numSubThreads = (numThreads > 1) ? 2 : 1; - UInt32 numBigThreads = numThreads / numSubThreads; - return (kBufferSize + kCompressedBufferSize + - GetLZMAUsage((numThreads > 1), dictionary) + (2 << 20)) * numBigThreads; + const UInt32 kCompressedBufferSize = kBufferSize; // / 2; + bool lzmaMt = (totalBench || numThreads > 1); + UInt32 numBigThreads = numThreads; + if (!totalBench && lzmaMt) + numBigThreads /= 2; + return ((UInt64)kBufferSize + kCompressedBufferSize + + GetLZMAUsage(lzmaMt, dictionary) + (2 << 20)) * numBigThreads; } static HRESULT CrcBig(const void *data, UInt32 size, UInt64 numIterations, @@ -1829,7 +1980,11 @@ void PrintRight(IBenchPrintCallback &f, const char *s, unsigned size) static HRESULT TotalBench( DECL_EXTERNAL_CODECS_LOC_VARS UInt64 complexInCommands, - UInt32 numThreads, bool forceUnpackSize, UInt32 unpackSize, IBenchPrintCallback *printCallback, CBenchCallbackToPrint *callback) + UInt32 numThreads, + bool forceUnpackSize, + size_t unpackSize, + const Byte *fileData, + IBenchPrintCallback *printCallback, CBenchCallbackToPrint *callback) { for (unsigned i = 0; i < ARRAY_SIZE(g_Bench); i++) { @@ -1838,12 +1993,13 @@ static HRESULT TotalBench( callback->BenchProps.DecComplexUnc = bench.DecComplexUnc; callback->BenchProps.DecComplexCompr = bench.DecComplexCompr; callback->BenchProps.EncComplex = bench.EncComplex; + COneMethodInfo method; NCOM::CPropVariant propVariant; propVariant = bench.Name; RINOK(method.ParseMethodFromPROPVARIANT(UString(), propVariant)); - UInt32 unpackSize2 = unpackSize; + size_t unpackSize2 = unpackSize; if (!forceUnpackSize && bench.DictBits == 0) unpackSize2 = kFilterUnpackSize; @@ -1853,8 +2009,11 @@ static HRESULT TotalBench( HRESULT res = MethodBench( EXTERNAL_CODECS_LOC_VARS complexInCommands, - false, numThreads, method, unpackSize2, bench.DictBits, + false, numThreads, method, + unpackSize2, fileData, + bench.DictBits, printCallback, callback, &callback->BenchProps); + if (res == E_NOTIMPL) { // callback->Print(" ---"); @@ -1866,6 +2025,7 @@ static HRESULT TotalBench( { RINOK(res); } + callback->NewLine(); } return S_OK; @@ -1877,6 +2037,7 @@ static HRESULT FreqBench( UInt32 numThreads, IBenchPrintCallback *_file, bool showFreq, + UInt64 specifiedFreq, UInt64 &cpuFreq, UInt32 &res) { @@ -1938,6 +2099,7 @@ static HRESULT FreqBench( } res += sum; } + CBenchInfo info; progressInfoSpec.SetFinishTime(info); @@ -1954,7 +2116,7 @@ static HRESULT FreqBench( PrintResults(_file, info, 0, // weight rating, - showFreq, showFreq ? cpuFreq : 0, NULL); + showFreq, showFreq ? (specifiedFreq != 0 ? specifiedFreq : cpuFreq) : 0, NULL); } RINOK(_file->CheckBreak()); } @@ -2275,6 +2437,7 @@ void GetCpuName(AString &s) #endif } + HRESULT Bench( DECL_EXTERNAL_CODECS_LOC_VARS IBenchPrintCallback *printCallback, @@ -2301,23 +2464,86 @@ HRESULT Bench( UInt32 testTime = kComplexInSeconds; + UInt64 specifiedFreq = 0; + bool multiThreadTests = false; COneMethodInfo method; unsigned i; + + CBenchBuffer fileDataBuffer; + for (i = 0; i < props.Size(); i++) { const CProperty &property = props[i]; - NCOM::CPropVariant propVariant; UString name = property.Name; name.MakeLower_Ascii(); + + if (name.IsEqualTo("file")) + { + if (property.Value.IsEmpty()) + return E_INVALIDARG; + + #ifdef USE_WIN_FILE + + NFile::NIO::CInFile file; + if (!file.Open(property.Value)) + return E_INVALIDARG; + UInt64 len; + if (!file.GetLength(len)) + return E_FAIL; + if (len >= ((UInt32)1 << 31) || len == 0) + return E_INVALIDARG; + if (!fileDataBuffer.Alloc((size_t)len)) + return E_OUTOFMEMORY; + UInt32 processedSize; + file.Read(fileDataBuffer.Buffer, (UInt32)len, processedSize); + if (processedSize != len) + return E_FAIL; + if (printCallback) + { + printCallback->Print("file size ="); + // printCallback->Print(GetOemString(property.Value)); + PrintNumber(*printCallback, len, 0); + printCallback->NewLine(); + } + continue; + + #else + + return E_NOTIMPL; + + #endif + } + + NCOM::CPropVariant propVariant; if (!property.Value.IsEmpty()) ParseNumberString(property.Value, propVariant); - if (name.IsEqualTo("testtime")) + + if (name.IsEqualTo("time")) { RINOK(ParsePropToUInt32(L"", propVariant, testTime)); continue; } + + if (name.IsEqualTo("freq")) + { + UInt32 freq32 = 0; + RINOK(ParsePropToUInt32(L"", propVariant, freq32)); + if (freq32 == 0) + return E_INVALIDARG; + specifiedFreq = (UInt64)freq32 * 1000000; + + if (printCallback) + { + printCallback->Print("freq="); + PrintNumber(*printCallback, freq32, 0); + printCallback->NewLine(); + } + + continue; + } + if (name.IsPrefixedBy_Ascii_NoCase("mt")) { UString s = name.Ptr(2); @@ -2339,6 +2565,7 @@ HRESULT Bench( #endif continue; } + RINOK(method.ParseMethodFromPROPVARIANT(name, propVariant)); } @@ -2359,7 +2586,12 @@ HRESULT Bench( if (printCallback /* || benchCallback */) { - UInt64 numMilCommands = (1 << 6); + UInt64 numMilCommands = 1 << 6; + if (specifiedFreq != 0) + { + while (numMilCommands > 1 && specifiedFreq < (numMilCommands * 1000000)) + numMilCommands >>= 1; + } for (int jj = 0;; jj++) { @@ -2369,22 +2601,33 @@ HRESULT Bench( UInt64 start = ::GetTimeCount(); UInt32 sum = (UInt32)start; sum = CountCpuFreq(sum, (UInt32)(numMilCommands * 1000000 / kNumFreqCommands), g_BenchCpuFreqTemp); - start = ::GetTimeCount() - start; + const UInt64 realDelta = ::GetTimeCount() - start; + start = realDelta; if (start == 0) start = 1; UInt64 freq = GetFreq(); - UInt64 mips = numMilCommands * freq / start; + // mips is constant in some compilers + const UInt64 mipsVal = numMilCommands * freq / start; if (printCallback) - PrintNumber(*printCallback, mips, 5 + ((sum == 0xF1541213) ? 1 : 0)); - + { + if (realDelta == 0) + { + printCallback->Print(" -"); + } + else + { + // PrintNumber(*printCallback, start, 0); + PrintNumber(*printCallback, mipsVal, 5 + ((sum == 0xF1541213) ? 1 : 0)); + } + } /* if (benchCallback) - benchCallback->AddCpuFreq(mips); + benchCallback->AddCpuFreq(mipsVal); */ if (jj >= 3) { - SetComplexCommands(testTime, mips * 1000000, complexInCommands); + SetComplexCommands(testTime, false, mipsVal * 1000000, complexInCommands); if (jj >= 8 || start >= freq) break; // break; // change it @@ -2419,7 +2662,8 @@ HRESULT Bench( EXTERNAL_CODECS_LOC_VARS complexInCommands, true, numThreadsSpecified, - method, uncompressedDataSize, + method, + uncompressedDataSize, fileDataBuffer.Buffer, kOldLzmaDictBits, printCallback, benchCallback, &benchProps); } @@ -2533,6 +2777,12 @@ HRESULT Bench( bool use2Columns = false; bool totalBenchMode = (method.MethodName.IsEqualTo_Ascii_NoCase("*")); + bool onlyHashBench = false; + if (method.MethodName.IsEqualTo_Ascii_NoCase("hash")) + { + onlyHashBench = true; + totalBenchMode = true; + } // ---------- Threads loop ---------- for (unsigned threadsPassIndex = 0; threadsPassIndex < 3; threadsPassIndex++) @@ -2577,14 +2827,28 @@ HRESULT Bench( if (!dictIsDefined) { - unsigned dicSizeLog = (totalBenchMode ? 24 : 25); + const unsigned dicSizeLog_Main = (totalBenchMode ? 24 : 25); + unsigned dicSizeLog = dicSizeLog_Main; + + #ifdef UNDER_CE + dicSizeLog = (UInt64)1 << 20; + #endif + for (; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--) - if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize) + if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog), totalBenchMode) + (8 << 20) <= ramSize) break; + dict = (UInt32)1 << dicSizeLog; + + if (totalBenchMode && dicSizeLog != dicSizeLog_Main) + { + f.Print("Dictionary reduced to: "); + PrintNumber(f, dicSizeLog, 1); + f.NewLine(); + } } - PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dict), "Benchmark threads: ", numThreads); + PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dict, totalBenchMode), "Benchmark threads: ", numThreads); f.NewLine(); @@ -2664,15 +2928,12 @@ HRESULT Bench( f.NewLine(); f.NewLine(); + if (specifiedFreq != 0) + cpuFreq = specifiedFreq; + + if (totalBenchMode) { - if (!dictIsDefined) - dict = - #ifdef UNDER_CE - (UInt64)1 << 20; - #else - (UInt64)1 << 24; - #endif for (UInt32 i = 0; i < numIterations; i++) { if (i != 0) @@ -2685,17 +2946,32 @@ HRESULT Bench( { PrintLeft(f, "CPU", kFieldSize_Name); UInt32 resVal; - RINOK(FreqBench(complexInCommands, numThreads, printCallback, freqTest == kNumCpuTests - 1, cpuFreq, resVal)); + RINOK(FreqBench(complexInCommands, numThreads, printCallback, + (freqTest == kNumCpuTests - 1 || specifiedFreq != 0), // showFreq + specifiedFreq, + cpuFreq, resVal)); callback.NewLine(); + if (specifiedFreq != 0) + cpuFreq = specifiedFreq; + if (freqTest == kNumCpuTests - 1) - SetComplexCommands(testTime, cpuFreq, complexInCommands); + SetComplexCommands(testTime, specifiedFreq != 0, cpuFreq, complexInCommands); } callback.NewLine(); callback.SetFreq(true, cpuFreq); - res = TotalBench(EXTERNAL_CODECS_LOC_VARS complexInCommands, numThreads, dictIsDefined, dict, printCallback, &callback); - RINOK(res); + + if (!onlyHashBench) + { + res = TotalBench(EXTERNAL_CODECS_LOC_VARS + complexInCommands, numThreads, + dictIsDefined || fileDataBuffer.Buffer, // forceUnpackSize + fileDataBuffer.Buffer ? fileDataBuffer.BufferSize : dict, + fileDataBuffer.Buffer, + printCallback, &callback); + RINOK(res); + } res = TotalBench_Hash(EXTERNAL_CODECS_LOC_VARS complexInCommands, numThreads, 1 << kNumHashDictBits, printCallback, &callback, &callback.EncodeRes, true, cpuFreq); @@ -2706,7 +2982,10 @@ HRESULT Bench( PrintLeft(f, "CPU", kFieldSize_Name); UInt32 resVal; UInt64 cpuFreqLastTemp = cpuFreq; - RINOK(FreqBench(complexInCommands, numThreads, printCallback, false, cpuFreqLastTemp, resVal)); + RINOK(FreqBench(complexInCommands, numThreads, printCallback, + specifiedFreq != 0, // showFreq + specifiedFreq, + cpuFreqLastTemp, resVal)); callback.NewLine(); } } @@ -2762,15 +3041,24 @@ HRESULT Bench( RINOK(method2.ParseMethodFromPROPVARIANT(L"d", propVariant)); } - UInt32 uncompressedDataSize = callback.DictSize; - if (uncompressedDataSize >= (1 << 18)) - uncompressedDataSize += kAdditionalSize; + size_t uncompressedDataSize; + if (fileDataBuffer.Buffer) + { + uncompressedDataSize = fileDataBuffer.BufferSize; + } + else + { + uncompressedDataSize = callback.DictSize; + if (uncompressedDataSize >= (1 << 18)) + uncompressedDataSize += kAdditionalSize; + } HRESULT res = MethodBench( EXTERNAL_CODECS_LOC_VARS complexInCommands, true, numThreads, - method2, uncompressedDataSize, + method2, + uncompressedDataSize, fileDataBuffer.Buffer, kOldLzmaDictBits, printCallback, &callback, &callback.BenchProps); f.NewLine(); RINOK(res); diff --git a/CPP/7zip/UI/Common/Bench.h b/CPP/7zip/UI/Common/Bench.h index b123675b..841250ef 100644 --- a/CPP/7zip/UI/Common/Bench.h +++ b/CPP/7zip/UI/Common/Bench.h @@ -32,9 +32,9 @@ struct IBenchCallback UInt64 GetCompressRating(UInt32 dictSize, UInt64 elapsedTime, UInt64 freq, UInt64 size); UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt64 numIterations); -const int kBenchMinDicLogSize = 18; +const unsigned kBenchMinDicLogSize = 18; -UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary); +UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary, bool totalBench = false); struct IBenchPrintCallback { diff --git a/CPP/7zip/UI/Common/UpdateCallback.cpp b/CPP/7zip/UI/Common/UpdateCallback.cpp index ac57e1a9..ea8f47e1 100644 --- a/CPP/7zip/UI/Common/UpdateCallback.cpp +++ b/CPP/7zip/UI/Common/UpdateCallback.cpp @@ -14,7 +14,6 @@ #include "../../../Windows/FileDir.h" #include "../../../Windows/FileName.h" #include "../../../Windows/PropVariant.h" -#include "../../../Windows/Synchronization.h" #include "../../Common/StreamObjects.h" @@ -429,7 +428,9 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR COM_TRY_END } +#ifndef _7ZIP_ST static NSynchronization::CCriticalSection CS; +#endif STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStream **inStream, UInt32 mode) { @@ -536,7 +537,9 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream2(UInt32 index, ISequentialInStrea if (ProcessedItemsStatuses) { + #ifndef _7ZIP_ST NSynchronization::CCriticalSectionLock lock(CS); + #endif ProcessedItemsStatuses[(unsigned)up.DirIndex] = 1; } *inStream = inStreamLoc.Detach(); diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp index cc0b1f93..652b30f7 100644 --- a/CPP/7zip/UI/Console/Main.cpp +++ b/CPP/7zip/UI/Console/Main.cpp @@ -158,7 +158,7 @@ static const char *kHelpString = " -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName] : Update options\n" " -v{Size}[b|k|m|g] : Create volumes\n" " -w[{path}] : assign Work directory. Empty path means a temporary directory\n" - " -x[r[-|0]]]{@listfile|!wildcard} : eXclude filenames\n" + " -x[r[-|0]]{@listfile|!wildcard} : eXclude filenames\n" " -y : assume Yes on all queries\n"; // --------------------------- diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h index 63b97a25..bb579947 100644 --- a/CPP/7zip/UI/FileManager/Panel.h +++ b/CPP/7zip/UI/FileManager/Panel.h @@ -698,15 +698,26 @@ public: void OpenFolder(int index); HRESULT OpenParentArchiveFolder(); - HRESULT OpenItemAsArchive(IInStream *inStream, + + HRESULT OpenAsArc(IInStream *inStream, const CTempFileInfo &tempFileInfo, const UString &virtualFilePath, const UString &arcFormat, bool &encrypted); - HRESULT OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted); - HRESULT OpenItemAsArchive(int index, const wchar_t *type = NULL); + + HRESULT OpenAsArc_Msg(IInStream *inStream, + const CTempFileInfo &tempFileInfo, + const UString &virtualFilePath, + const UString &arcFormat, + bool &encrypted, + bool showErrorMessage); + + HRESULT OpenAsArc_Name(const UString &relPath, const UString &arcFormat, bool &encrypted, bool showErrorMessage); + HRESULT OpenAsArc_Index(int index, const wchar_t *type /* = NULL */, bool showErrorMessage); + void OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode, bool useEditor, const wchar_t *type = NULL); + HRESULT OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath, bool usePassword, const UString &password); LRESULT OnOpenItemChanged(LPARAM lParam); diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp index dd8d3029..e4fbb5b3 100644 --- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp +++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp @@ -183,13 +183,13 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo FString dirPrefix, fileName; NDir::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName); HRESULT res; - // = OpenItemAsArchive(fs2us(fileName), arcFormat, encrypted); + // = OpenAsArc(fs2us(fileName), arcFormat, encrypted); { CTempFileInfo tfi; tfi.RelPath = fs2us(fileName); tfi.FolderPath = dirPrefix; tfi.FilePath = us2fs(sysPath); - res = OpenItemAsArchive(NULL, tfi, sysPath, arcFormat, encrypted); + res = OpenAsArc(NULL, tfi, sysPath, arcFormat, encrypted); } if (res == S_FALSE) @@ -204,6 +204,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo path.Delete(0); } } + if (newFolder) { SetNewFolder(newFolder); diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp index 6658923f..a4ab254d 100644 --- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp +++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp @@ -27,6 +27,8 @@ #include "RegistryUtils.h" #include "UpdateCallback100.h" +#include "../GUI/ExtractRes.h" + #include "resource.h" using namespace NWindows; @@ -182,7 +184,8 @@ public: } }; -HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, + +HRESULT CPanel::OpenAsArc(IInStream *inStream, const CTempFileInfo &tempFileInfo, const UString &virtualFilePath, const UString &arcFormat, @@ -191,6 +194,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, encrypted = false; CFolderLink folderLink; (CTempFileInfo &)folderLink = tempFileInfo; + if (inStream) folderLink.IsVirtual = true; else @@ -224,6 +228,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, folderLink.ParentFolderPath = GetFolderPath(_folder); else folderLink.ParentFolderPath = _currentFolderPrefix; + if (!_parentFolders.IsEmpty()) folderLink.ParentFolder = _folder; @@ -240,6 +245,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, CMyComPtr<IGetFolderArcProps> getFolderArcProps; _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps); _thereAreDeletedItems = false; + if (getFolderArcProps) { CMyComPtr<IFolderArcProps> arcProps; @@ -304,22 +310,58 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, return S_OK; } -HRESULT CPanel::OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted) + +HRESULT CPanel::OpenAsArc_Msg(IInStream *inStream, + const CTempFileInfo &tempFileInfo, + const UString &virtualFilePath, + const UString &arcFormat, + bool &encrypted, + bool showErrorMessage) +{ + HRESULT res = OpenAsArc(inStream, tempFileInfo, virtualFilePath, arcFormat, encrypted); + + if (res == S_OK) + return res; + if (res == E_ABORT) + return res; + + if (showErrorMessage && encrypted) + { + UString message = L"Error"; + if (res == S_FALSE) + { + message = MyFormatNew( + encrypted ? + IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : + IDS_CANT_OPEN_ARCHIVE, + virtualFilePath); + } + else + message = HResultToMessage(res); + MessageBoxMyError(message); + } + + return res; +} + + +HRESULT CPanel::OpenAsArc_Name(const UString &relPath, const UString &arcFormat, bool &encrypted, bool showErrorMessage) { CTempFileInfo tfi; tfi.RelPath = relPath; tfi.FolderPath = us2fs(GetFsPath()); const UString fullPath = GetFsPath() + relPath; tfi.FilePath = us2fs(fullPath); - return OpenItemAsArchive(NULL, tfi, fullPath, arcFormat, encrypted); + return OpenAsArc_Msg(NULL, tfi, fullPath, arcFormat, encrypted, showErrorMessage); } -HRESULT CPanel::OpenItemAsArchive(int index, const wchar_t *type) + +HRESULT CPanel::OpenAsArc_Index(int index, const wchar_t *type, bool showErrorMessage) { CDisableTimerProcessing disableTimerProcessing1(*this); CDisableNotify disableNotify(*this); bool encrypted; - HRESULT res = OpenItemAsArchive(GetItemRelPath2(index), type ? type : L"", encrypted); + HRESULT res = OpenAsArc_Name(GetItemRelPath2(index), type ? type : L"", encrypted, showErrorMessage); if (res != S_OK) { RefreshTitle(true); // in case of error we must refresh changed title of 7zFM @@ -329,6 +371,7 @@ HRESULT CPanel::OpenItemAsArchive(int index, const wchar_t *type) return S_OK; } + HRESULT CPanel::OpenParentArchiveFolder() { CDisableTimerProcessing disableTimerProcessing(*this); @@ -359,6 +402,7 @@ HRESULT CPanel::OpenParentArchiveFolder() return S_OK; } + static const char *kStartExtensions = #ifdef UNDER_CE " cab" @@ -668,6 +712,7 @@ bool CPanel::IsVirus_Message(const UString &name) return true; } + void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar_t *type) { CDisableTimerProcessing disableTimerProcessing(*this); @@ -689,7 +734,7 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar if (tryInternal) if (!tryExternal || !DoItemAlwaysStart(name)) { - HRESULT res = OpenItemAsArchive(index, type); + HRESULT res = OpenAsArc_Index(index, type, true); disableNotify.Restore(); // we must restore to allow text notification update InvalidateList(); if (res == S_OK || res == E_ABORT) @@ -1069,22 +1114,18 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo if (subStream) { bool encrypted; - HRESULT res = OpenItemAsArchive(subStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted); + HRESULT res = OpenAsArc_Msg(subStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true); if (res == S_OK) { tempDirectory.DisableDeleting(); RefreshListCtrl(); return; } - if (res == E_ABORT) + if (res == E_ABORT || res != S_FALSE) return; - if (res != S_FALSE) - { - // probably we must show some message here - // return; - } if (!tryExternal) return; + tryAsArchive = false; } } } @@ -1183,12 +1224,21 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo CMyComPtr<IInStream> bufInStream = bufInStreamSpec; bufInStreamSpec->Init(file.Data, streamSize, virtFileSystem); bool encrypted; - if (OpenItemAsArchive(bufInStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted) == S_OK) + + HRESULT res = OpenAsArc_Msg(bufInStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true); + if (res == S_OK) { tempDirectory.DisableDeleting(); RefreshListCtrl(); return; } + + if (res == E_ABORT || res != S_FALSE) + return; + if (!tryExternal) + return; + + tryAsArchive = false; if (virtFileSystemSpec->FlushToDisk(true) != S_OK) return; } @@ -1209,14 +1259,20 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo if (tryAsArchive) { bool encrypted; - if (OpenItemAsArchive(NULL, tempFileInfo, fullVirtPath, type ? type : L"", encrypted) == S_OK) + HRESULT res = OpenAsArc_Msg(NULL, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true); + if (res == S_OK) { tempDirectory.DisableDeleting(); RefreshListCtrl(); return; } + if (res == E_ABORT || res != S_FALSE) + return; } + if (!tryExternal) + return; + CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr(new CTmpProcessInfo()); CTmpProcessInfo *tpi = tmpProcessInfoPtr.get(); tpi->FolderPath = tempDir; @@ -1230,9 +1286,6 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo CTmpProcessInfoRelease tmpProcessInfoRelease(*tpi); - if (!tryExternal) - return; - CProcess process; // HRESULT res; if (editMode) diff --git a/CPP/7zip/UI/FileManager/PanelSelect.cpp b/CPP/7zip/UI/FileManager/PanelSelect.cpp index de9cf4b5..72cb4838 100644 --- a/CPP/7zip/UI/FileManager/PanelSelect.cpp +++ b/CPP/7zip/UI/FileManager/PanelSelect.cpp @@ -82,20 +82,21 @@ void CPanel::OnInsert() LVIS_CUT : 0; _listView.SetItemState(focusedItem, state, LVIS_CUT); // _listView.SetItemState_Selected(focusedItem); - */ + int focusedItem = _listView.GetFocusedItem(); if (focusedItem < 0) return; + int realIndex = GetRealItemIndex(focusedItem); - bool isSelected = !_selectedStatusVector[realIndex]; if (realIndex != kParentIndex) + { + bool isSelected = !_selectedStatusVector[realIndex]; _selectedStatusVector[realIndex] = isSelected; - - if (!_mySelectMode) - _listView.SetItemState_Selected(focusedItem, isSelected); - - _listView.RedrawItem(focusedItem); + if (!_mySelectMode) + _listView.SetItemState_Selected(focusedItem, isSelected); + _listView.RedrawItem(focusedItem); + } int nextIndex = focusedItem + 1; if (nextIndex < _listView.GetItemCount()) @@ -112,6 +113,8 @@ void CPanel::OnUpWithShift() if (focusedItem < 0) return; int index = GetRealItemIndex(focusedItem); + if (index == kParentIndex) + return; _selectedStatusVector[index] = !_selectedStatusVector[index]; _listView.RedrawItem(index); } @@ -122,6 +125,8 @@ void CPanel::OnDownWithShift() if (focusedItem < 0) return; int index = GetRealItemIndex(focusedItem); + if (index == kParentIndex) + return; _selectedStatusVector[index] = !_selectedStatusVector[index]; _listView.RedrawItem(index); } diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp index 41173e1f..e210f0d1 100644 --- a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp +++ b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp @@ -71,11 +71,13 @@ static const LPCTSTR kMB = TEXT(" MB"); static const LPCTSTR kMIPS = TEXT(" MIPS"); static const LPCTSTR kKBs = TEXT(" KB/s"); -#ifdef UNDER_CE -static const int kMinDicLogSize = 20; -#else -static const int kMinDicLogSize = 21; -#endif +static const unsigned kMinDicLogSize = + #ifdef UNDER_CE + 20; + #else + 21; + #endif + static const UInt32 kMinDicSize = (1 << kMinDicLogSize); static const UInt32 kMaxDicSize = #ifdef MY_CPU_64BIT @@ -185,29 +187,28 @@ bool CBenchmarkDialog::OnInit() if (Sync.DictionarySize == (UInt32)(Int32)-1) { - int dicSizeLog; + unsigned dicSizeLog; for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--) if (GetBenchMemoryUsage(Sync.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize) break; Sync.DictionarySize = (1 << dicSizeLog); } - if (Sync.DictionarySize < kMinDicSize) - Sync.DictionarySize = kMinDicSize; - if (Sync.DictionarySize > kMaxDicSize) - Sync.DictionarySize = kMaxDicSize; + + if (Sync.DictionarySize < kMinDicSize) Sync.DictionarySize = kMinDicSize; + if (Sync.DictionarySize > kMaxDicSize) Sync.DictionarySize = kMaxDicSize; - for (int i = kMinDicLogSize; i <= 30; i++) - for (int j = 0; j < 2; j++) + for (unsigned i = kMinDicLogSize; i <= 30; i++) + for (unsigned j = 0; j < 2; j++) { - UInt32 dictionary = (1 << i) + (j << (i - 1)); - if (dictionary > kMaxDicSize) + UInt32 dict = (1 << i) + (j << (i - 1)); + if (dict > kMaxDicSize) continue; TCHAR s[16]; - ConvertUInt32ToString((dictionary >> 20), s); + ConvertUInt32ToString((dict >> 20), s); lstrcat(s, kMB); int index = (int)m_Dictionary.AddString(s); - m_Dictionary.SetItemData(index, dictionary); - if (dictionary <= Sync.DictionarySize) + m_Dictionary.SetItemData(index, dict); + if (dict <= Sync.DictionarySize) cur = index; } m_Dictionary.SetCurSel(cur); @@ -265,14 +266,14 @@ UInt32 CBenchmarkDialog::GetNumberOfThreads() UInt32 CBenchmarkDialog::OnChangeDictionary() { - UInt32 dictionary = (UInt32)m_Dictionary.GetItemData_of_CurSel(); - UInt64 memUsage = GetBenchMemoryUsage(GetNumberOfThreads(), dictionary); + UInt32 dict = (UInt32)m_Dictionary.GetItemData_of_CurSel(); + UInt64 memUsage = GetBenchMemoryUsage(GetNumberOfThreads(), dict); memUsage = (memUsage + (1 << 20) - 1) >> 20; TCHAR s[40]; ConvertUInt64ToString(memUsage, s); lstrcat(s, kMB); SetItemText(IDT_BENCH_MEMORY_VAL, s); - return dictionary; + return dict; } static const UInt32 g_IDs[] = @@ -303,7 +304,7 @@ static const UInt32 g_IDs[] = void CBenchmarkDialog::OnChangeSettings() { EnableItem(IDB_STOP, true); - UInt32 dictionary = OnChangeDictionary(); + UInt32 dict = OnChangeDictionary(); for (int i = 0; i < ARRAY_SIZE(g_IDs); i++) SetItemText(g_IDs[i], kProcessingString); @@ -311,7 +312,7 @@ void CBenchmarkDialog::OnChangeSettings() PrintTime(); NWindows::NSynchronization::CCriticalSectionLock lock(Sync.CS); Sync.Init(); - Sync.DictionarySize = dictionary; + Sync.DictionarySize = dict; Sync.Changed = true; Sync.NumThreads = GetNumberOfThreads(); } |