Home | History | Annotate | Download | only in Common
      1 // InStreamWithCRC.cpp
      2 
      3 #include "StdAfx.h"
      4 
      5 #include "InStreamWithCRC.h"
      6 
      7 STDMETHODIMP CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize)
      8 {
      9   UInt32 realProcessedSize;
     10   HRESULT result = _stream->Read(data, size, &realProcessedSize);
     11   _size += realProcessedSize;
     12   if (size > 0 && realProcessedSize == 0)
     13     _wasFinished = true;
     14   _crc = CrcUpdate(_crc, data, realProcessedSize);
     15   if(processedSize != NULL)
     16     *processedSize = realProcessedSize;
     17   return result;
     18 }
     19 
     20 STDMETHODIMP CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize)
     21 {
     22   UInt32 realProcessedSize;
     23   HRESULT result = _stream->Read(data, size, &realProcessedSize);
     24   /*
     25   if (size > 0 && realProcessedSize == 0)
     26     _wasFinished = true;
     27   */
     28   _size += realProcessedSize;
     29   _crc = CrcUpdate(_crc, data, realProcessedSize);
     30   if(processedSize != NULL)
     31     *processedSize = realProcessedSize;
     32   return result;
     33 }
     34 
     35 STDMETHODIMP CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
     36 {
     37   if (seekOrigin != STREAM_SEEK_SET || offset != 0)
     38     return E_FAIL;
     39   _size = 0;
     40   _crc = CRC_INIT_VAL;
     41   return _stream->Seek(offset, seekOrigin, newPosition);
     42 }
     43