misc/libphysfs/lzma/CPP/7zip/Common/LimitedStreams.cpp
changeset 13881 99b265e0d1d0
parent 13880 5f819b90d479
child 13882 b172a5d40eee
equal deleted inserted replaced
13880:5f819b90d479 13881:99b265e0d1d0
     1 // LimitedStreams.cpp
       
     2 
       
     3 #include "StdAfx.h"
       
     4 
       
     5 #include "LimitedStreams.h"
       
     6 #include "../../Common/Defs.h"
       
     7 
       
     8 STDMETHODIMP 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