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