1 // OutStreamWithSha1.cpp
2
3 #include "StdAfx.h"
4
5 #include "OutStreamWithSha1.h"
6
Z7_COM7F_IMF(COutStreamWithSha1::Write (const void * data,UInt32 size,UInt32 * processedSize))7 Z7_COM7F_IMF(COutStreamWithSha1::Write(const void *data, UInt32 size, UInt32 *processedSize))
8 {
9 HRESULT result = S_OK;
10 if (_stream)
11 result = _stream->Write(data, size, &size);
12 if (_calculate)
13 Sha1_Update(Sha(), (const Byte *)data, size);
14 _size += size;
15 if (processedSize)
16 *processedSize = size;
17 return result;
18 }
19
Z7_COM7F_IMF(CInStreamWithSha1::Read (void * data,UInt32 size,UInt32 * processedSize))20 Z7_COM7F_IMF(CInStreamWithSha1::Read(void *data, UInt32 size, UInt32 *processedSize))
21 {
22 UInt32 realProcessedSize;
23 const HRESULT result = _stream->Read(data, size, &realProcessedSize);
24 _size += realProcessedSize;
25 Sha1_Update(Sha(), (const Byte *)data, realProcessedSize);
26 if (processedSize)
27 *processedSize = realProcessedSize;
28 return result;
29 }
30