From acd742622d1e0daf50ae815bec4ddb2143bafbf5 Mon Sep 17 00:00:00 2001 From: Igor Pavlov Date: Wed, 24 Oct 2007 00:00:00 +0000 Subject: 4.56 beta --- CPP/7zip/Archive/7z/7zExtract.cpp | 2 +- CPP/7zip/Archive/7z/7zFolderInStream.cpp | 9 +++++---- CPP/7zip/Archive/7z/7zFolderOutStream.cpp | 9 ++++++--- CPP/7zip/Archive/7z/7zFolderOutStream.h | 5 ++++- CPP/7zip/Archive/7z/7zHandler.cpp | 2 ++ CPP/7zip/Archive/7z/7zHandler.h | 4 +++- 6 files changed, 21 insertions(+), 10 deletions(-) (limited to 'CPP/7zip/Archive/7z') diff --git a/CPP/7zip/Archive/7z/7zExtract.cpp b/CPP/7zip/Archive/7z/7zExtract.cpp index 65f9c9eb..42977097 100755 --- a/CPP/7zip/Archive/7z/7zExtract.cpp +++ b/CPP/7zip/Archive/7z/7zExtract.cpp @@ -195,7 +195,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, 0, #endif startIndex, - &efi.ExtractStatuses, extractCallback, testMode); + &efi.ExtractStatuses, extractCallback, testMode, _crcSize != 0); RINOK(result); diff --git a/CPP/7zip/Archive/7z/7zFolderInStream.cpp b/CPP/7zip/Archive/7z/7zFolderInStream.cpp index fb1cfd3a..f60a7177 100755 --- a/CPP/7zip/Archive/7z/7zFolderInStream.cpp +++ b/CPP/7zip/Archive/7z/7zFolderInStream.cpp @@ -113,13 +113,14 @@ STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSiz STDMETHODIMP CFolderInStream::GetSubStreamSize(UInt64 subStream, UInt64 *value) { *value = 0; - if (subStream < Sizes.Size()) + int subStreamIndex = (int)subStream; + if (subStreamIndex < 0 || subStream > Sizes.Size()) + return E_FAIL; + if (subStreamIndex < Sizes.Size()) { - *value= Sizes[(int)(size_t)subStream]; + *value= Sizes[subStreamIndex]; return S_OK; } - if (subStream > Sizes.Size()) - return E_FAIL; if (!_currentSizeIsDefined) return S_FALSE; *value = _currentSize; diff --git a/CPP/7zip/Archive/7z/7zFolderOutStream.cpp b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp index 93bed3d9..6206ffec 100755 --- a/CPP/7zip/Archive/7z/7zFolderOutStream.cpp +++ b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp @@ -19,7 +19,8 @@ HRESULT CFolderOutStream::Init( UInt32 startIndex, const CBoolVector *extractStatuses, IArchiveExtractCallback *extractCallback, - bool testMode) + bool testMode, + bool checkCrc) { _archiveDatabase = archiveDatabase; _ref2Offset = ref2Offset; @@ -29,6 +30,8 @@ HRESULT CFolderOutStream::Init( _extractCallback = extractCallback; _testMode = testMode; + _checkCrc = checkCrc; + _currentIndex = 0; _fileIsOpen = false; return WriteEmptyFiles(); @@ -49,7 +52,7 @@ HRESULT CFolderOutStream::OpenFile() RINOK(_extractCallback->GetStream(_ref2Offset + index, &realOutStream, askMode)); _outStreamWithHashSpec->SetStream(realOutStream); - _outStreamWithHashSpec->Init(); + _outStreamWithHashSpec->Init(_checkCrc); if (askMode == NArchive::NExtract::NAskMode::kExtract && (!realOutStream)) { @@ -100,7 +103,7 @@ STDMETHODIMP CFolderOutStream::Write(const void *data, if (_filePos == fileSize) { bool digestsAreEqual; - if (fileInfo.IsFileCRCDefined) + if (fileInfo.IsFileCRCDefined && _checkCrc) digestsAreEqual = fileInfo.FileCRC == _outStreamWithHashSpec->GetCRC(); else digestsAreEqual = true; diff --git a/CPP/7zip/Archive/7z/7zFolderOutStream.h b/CPP/7zip/Archive/7z/7zFolderOutStream.h index c132c79a..8ca91e64 100755 --- a/CPP/7zip/Archive/7z/7zFolderOutStream.h +++ b/CPP/7zip/Archive/7z/7zFolderOutStream.h @@ -36,6 +36,8 @@ private: bool _testMode; bool _fileIsOpen; + + bool _checkCrc; UInt64 _filePos; HRESULT OpenFile(); @@ -47,7 +49,8 @@ public: UInt32 startIndex, const CBoolVector *extractStatuses, IArchiveExtractCallback *extractCallback, - bool testMode); + bool testMode, + bool checkCrc); HRESULT FlushCorrupted(Int32 resultEOperationResult); HRESULT WasWritingFinished(); }; diff --git a/CPP/7zip/Archive/7z/7zHandler.cpp b/CPP/7zip/Archive/7z/7zHandler.cpp index d5dc8720..bbef1ea5 100755 --- a/CPP/7zip/Archive/7z/7zHandler.cpp +++ b/CPP/7zip/Archive/7z/7zHandler.cpp @@ -33,6 +33,8 @@ namespace N7z { CHandler::CHandler() { + _crcSize = 4; + #ifdef EXTRACT_ONLY #ifdef COMPRESS_MT _numThreads = NWindows::NSystem::GetNumberOfProcessors(); diff --git a/CPP/7zip/Archive/7z/7zHandler.h b/CPP/7zip/Archive/7z/7zHandler.h index 1006f204..ad4df41f 100755 --- a/CPP/7zip/Archive/7z/7zHandler.h +++ b/CPP/7zip/Archive/7z/7zHandler.h @@ -110,7 +110,9 @@ private: #ifdef COMPRESS_MT UInt32 _numThreads; #endif - + + UInt32 _crcSize; + #else CRecordVector _binds; -- cgit v1.2.3