aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2023-06-21 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2023-12-17 14:59:19 +0500
commit5b39dc76f1bc82f941d5c800ab9f34407a06b53a (patch)
treefe5e17420300b715021a76328444088d32047963 /CPP/7zip/Archive/Common/InStreamWithCRC.cpp
parent93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (diff)
download7zip-23.01.tar.gz
7zip-23.01.tar.bz2
7zip-23.01.zip
23.0123.01
Diffstat (limited to 'CPP/7zip/Archive/Common/InStreamWithCRC.cpp')
-rw-r--r--CPP/7zip/Archive/Common/InStreamWithCRC.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/CPP/7zip/Archive/Common/InStreamWithCRC.cpp b/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
index a2d6883..735d5d1 100644
--- a/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
+++ b/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
@@ -4,22 +4,33 @@
4 4
5#include "InStreamWithCRC.h" 5#include "InStreamWithCRC.h"
6 6
7STDMETHODIMP CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize) 7Z7_COM7F_IMF(CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize))
8{ 8{
9 UInt32 realProcessed = 0; 9 UInt32 realProcessed = 0;
10 HRESULT result = S_OK; 10 HRESULT result = S_OK;
11 if (_stream) 11 if (size != 0)
12 result = _stream->Read(data, size, &realProcessed); 12 {
13 _size += realProcessed; 13 if (_stream)
14 if (size != 0 && realProcessed == 0) 14 result = _stream->Read(data, size, &realProcessed);
15 _wasFinished = true; 15 _size += realProcessed;
16 _crc = CrcUpdate(_crc, data, realProcessed); 16 if (realProcessed == 0)
17 _wasFinished = true;
18 else
19 _crc = CrcUpdate(_crc, data, realProcessed);
20 }
17 if (processedSize) 21 if (processedSize)
18 *processedSize = realProcessed; 22 *processedSize = realProcessed;
19 return result; 23 return result;
20} 24}
21 25
22STDMETHODIMP CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize) 26Z7_COM7F_IMF(CSequentialInStreamWithCRC::GetSize(UInt64 *size))
27{
28 *size = _fullSize;
29 return S_OK;
30}
31
32
33Z7_COM7F_IMF(CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize))
23{ 34{
24 UInt32 realProcessed = 0; 35 UInt32 realProcessed = 0;
25 HRESULT result = S_OK; 36 HRESULT result = S_OK;
@@ -36,7 +47,7 @@ STDMETHODIMP CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSi
36 return result; 47 return result;
37} 48}
38 49
39STDMETHODIMP CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) 50Z7_COM7F_IMF(CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition))
40{ 51{
41 if (seekOrigin != STREAM_SEEK_SET || offset != 0) 52 if (seekOrigin != STREAM_SEEK_SET || offset != 0)
42 return E_FAIL; 53 return E_FAIL;