misc/libphysfs/lzma/CPP/7zip/Common/LimitedStreams.cpp
author Wuzzy <almikes@aol.com>
Sat, 23 Sep 2017 07:38:41 +0200 (2017-09-23)
changeset 12504 d97050a7c074
parent 12218 bb5522e88ab2
permissions -rw-r--r--
Stop PhysFS from complaining when a random name .cfg file is missing
// LimitedStreams.cpp

#include "StdAfx.h"

#include "LimitedStreams.h"
#include "../../Common/Defs.h"

STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{
  UInt32 realProcessedSize = 0;
  UInt32 sizeToRead = (UInt32)MyMin((_size - _pos), (UInt64)size);
  HRESULT result = S_OK;
  if (sizeToRead > 0)
  {
    result = _stream->Read(data, sizeToRead, &realProcessedSize);
    _pos += realProcessedSize;
    if (realProcessedSize == 0)
      _wasFinished = true;
  }
  if(processedSize != NULL)
    *processedSize = realProcessedSize;
  return result;
}