michael@0: // LimitedStreams.cpp michael@0: michael@0: #include "StdAfx.h" michael@0: michael@0: #include "LimitedStreams.h" michael@0: #include "../../Common/Defs.h" michael@0: michael@0: void CLimitedSequentialInStream::Init(ISequentialInStream *stream, UInt64 streamSize) michael@0: { michael@0: _stream = stream; michael@0: _size = streamSize; michael@0: } michael@0: michael@0: STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize) michael@0: { michael@0: UInt32 processedSizeReal; michael@0: UInt32 sizeToRead = UInt32(MyMin(_size, UInt64(size))); michael@0: HRESULT result = _stream->Read(data, sizeToRead, &processedSizeReal); michael@0: _size -= processedSizeReal; michael@0: if(processedSize != NULL) michael@0: *processedSize = processedSizeReal; michael@0: return result; michael@0: } michael@0: