Mercurial > vba-linux
diff src/win32/7zip/7z/CPP/7zip/Archive/Common/InStreamWithCRC.cpp @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Archive/Common/InStreamWithCRC.cpp Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,40 @@ 1.4 +// InStreamWithCRC.cpp 1.5 + 1.6 +#include "StdAfx.h" 1.7 + 1.8 +#include "InStreamWithCRC.h" 1.9 + 1.10 +STDMETHODIMP CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize) 1.11 +{ 1.12 + UInt32 realProcessedSize; 1.13 + HRESULT result = _stream->Read(data, size, &realProcessedSize); 1.14 + _size += realProcessedSize; 1.15 + if (size > 0 && realProcessedSize == 0) 1.16 + _wasFinished = true; 1.17 + _crc = CrcUpdate(_crc, data, realProcessedSize); 1.18 + if(processedSize != NULL) 1.19 + *processedSize = realProcessedSize; 1.20 + return result; 1.21 +} 1.22 + 1.23 +STDMETHODIMP CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize) 1.24 +{ 1.25 + UInt32 realProcessedSize; 1.26 + HRESULT result = _stream->Read(data, size, &realProcessedSize); 1.27 + if (size > 0 && realProcessedSize == 0) 1.28 + _wasFinished = true; 1.29 + _size += realProcessedSize; 1.30 + _crc = CrcUpdate(_crc, data, realProcessedSize); 1.31 + if(processedSize != NULL) 1.32 + *processedSize = realProcessedSize; 1.33 + return result; 1.34 +} 1.35 + 1.36 +STDMETHODIMP CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) 1.37 +{ 1.38 + if (seekOrigin != STREAM_SEEK_SET || offset != 0) 1.39 + return E_FAIL; 1.40 + _size = 0; 1.41 + _crc = CRC_INIT_VAL; 1.42 + return _stream->Seek(offset, seekOrigin, newPosition); 1.43 +}