Mercurial > vba-linux
comparison 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 |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
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 if (size > 0 && realProcessedSize == 0) | |
25 _wasFinished = true; | |
26 _size += realProcessedSize; | |
27 _crc = CrcUpdate(_crc, data, realProcessedSize); | |
28 if(processedSize != NULL) | |
29 *processedSize = realProcessedSize; | |
30 return result; | |
31 } | |
32 | |
33 STDMETHODIMP CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) | |
34 { | |
35 if (seekOrigin != STREAM_SEEK_SET || offset != 0) | |
36 return E_FAIL; | |
37 _size = 0; | |
38 _crc = CRC_INIT_VAL; | |
39 return _stream->Seek(offset, seekOrigin, newPosition); | |
40 } |