"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "CPP/7zip/Common/LimitedStreams.cpp" between
p7zip_15.14.1_src_all.tar.gz and p7zip_16.02_src_all.tar.gz

About: p7zip is a command-line file archiver with a high compression ratio (a port of the Windows program 7za.exe).

LimitedStreams.cpp  (p7zip_15.14.1_src_all):LimitedStreams.cpp  (p7zip_16.02_src_all)
// LimitedStreams.cpp // LimitedStreams.cpp
#include "StdAfx.h" #include "StdAfx.h"
#include <string.h> #include <string.h>
#include "LimitedStreams.h" #include "LimitedStreams.h"
#include "../../Common/Defs.h"
STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *p rocessedSize) STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *p rocessedSize)
{ {
UInt32 realProcessedSize = 0; UInt32 realProcessedSize = 0;
UInt32 sizeToRead = (UInt32)MyMin((_size - _pos), (UInt64)size); {
const UInt64 rem = _size - _pos;
if (size > rem)
size = (UInt32)rem;
}
HRESULT result = S_OK; HRESULT result = S_OK;
if (sizeToRead > 0) if (size != 0)
{ {
result = _stream->Read(data, sizeToRead, &realProcessedSize); result = _stream->Read(data, size, &realProcessedSize);
_pos += realProcessedSize; _pos += realProcessedSize;
if (realProcessedSize == 0) if (realProcessedSize == 0)
_wasFinished = true; _wasFinished = true;
} }
if (processedSize) if (processedSize)
*processedSize = realProcessedSize; *processedSize = realProcessedSize;
return result; return result;
} }
STDMETHODIMP CLimitedInStream::Read(void *data, UInt32 size, UInt32 *processedSi ze) STDMETHODIMP CLimitedInStream::Read(void *data, UInt32 size, UInt32 *processedSi ze)
{ {
if (processedSize) if (processedSize)
*processedSize = 0; *processedSize = 0;
if (_virtPos >= _size) if (_virtPos >= _size)
{ {
// 9.31: Fixed. Windows doesn't return error in ReadFile and IStream->Read i n that case. // 9.31: Fixed. Windows doesn't return error in ReadFile and IStream->Read i n that case.
return S_OK; return S_OK;
// return (_virtPos == _size) ? S_OK: E_FAIL; // ERROR_HANDLE_EOF // return (_virtPos == _size) ? S_OK: E_FAIL; // ERROR_HANDLE_EOF
} }
UInt64 rem = _size - _virtPos; {
if (rem < size) const UInt64 rem = _size - _virtPos;
size = (UInt32)rem; if (size > rem)
size = (UInt32)rem;
}
UInt64 newPos = _startOffset + _virtPos; UInt64 newPos = _startOffset + _virtPos;
if (newPos != _physPos) if (newPos != _physPos)
{ {
_physPos = newPos; _physPos = newPos;
RINOK(SeekToPhys()); RINOK(SeekToPhys());
} }
HRESULT res = _stream->Read(data, size, &size); HRESULT res = _stream->Read(data, size, &size);
if (processedSize) if (processedSize)
*processedSize = size; *processedSize = size;
_physPos += size; _physPos += size;
 End of changes. 5 change blocks. 
7 lines changed or deleted 12 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS