1// LimitedStreams.cpp
2
3#include "StdAfx.h"
4
5#include "LimitedStreams.h"
6#include "../../Common/Defs.h"
7
8STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
9{
10  UInt32 realProcessedSize = 0;
11  UInt32 sizeToRead = (UInt32)MyMin((_size - _pos), (UInt64)size);
12  HRESULT result = S_OK;
13  if (sizeToRead > 0)
14  {
15    result = _stream->Read(data, sizeToRead, &realProcessedSize);
16    _pos += realProcessedSize;
17    if (realProcessedSize == 0)
18      _wasFinished = true;
19  }
20  if(processedSize != NULL)
21    *processedSize = realProcessedSize;
22  return result;
23}
24
25