1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/other-licenses/7zstub/src/7zip/Common/LimitedStreams.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,24 @@ 1.4 +// LimitedStreams.cpp 1.5 + 1.6 +#include "StdAfx.h" 1.7 + 1.8 +#include "LimitedStreams.h" 1.9 +#include "../../Common/Defs.h" 1.10 + 1.11 +void CLimitedSequentialInStream::Init(ISequentialInStream *stream, UInt64 streamSize) 1.12 +{ 1.13 + _stream = stream; 1.14 + _size = streamSize; 1.15 +} 1.16 + 1.17 +STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize) 1.18 +{ 1.19 + UInt32 processedSizeReal; 1.20 + UInt32 sizeToRead = UInt32(MyMin(_size, UInt64(size))); 1.21 + HRESULT result = _stream->Read(data, sizeToRead, &processedSizeReal); 1.22 + _size -= processedSizeReal; 1.23 + if(processedSize != NULL) 1.24 + *processedSize = processedSizeReal; 1.25 + return result; 1.26 +} 1.27 +