LimitedStreams.cpp 598 B

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