1 // InStreamWithCRC.h 2 3 #ifndef ZIP7_INC_IN_STREAM_WITH_CRC_H 4 #define ZIP7_INC_IN_STREAM_WITH_CRC_H 5 6 #include "../../../../C/7zCrc.h" 7 8 #include "../../../Common/MyCom.h" 9 10 #include "../../IStream.h" 11 12 Z7_CLASS_IMP_NOQIB_2( 13 CSequentialInStreamWithCRC 14 , ISequentialInStream 15 , IStreamGetSize 16 ) 17 CMyComPtr<ISequentialInStream> _stream; 18 UInt64 _size; 19 UInt32 _crc; 20 bool _wasFinished; 21 UInt64 _fullSize; 22 public: 23 CSequentialInStreamWithCRC()24 CSequentialInStreamWithCRC(): 25 _fullSize((UInt64)(Int64)-1) 26 {} 27 SetStream(ISequentialInStream * stream)28 void SetStream(ISequentialInStream *stream) { _stream = stream; } SetFullSize(UInt64 fullSize)29 void SetFullSize(UInt64 fullSize) { _fullSize = fullSize; } Init()30 void Init() 31 { 32 _size = 0; 33 _crc = CRC_INIT_VAL; 34 _wasFinished = false; 35 } ReleaseStream()36 void ReleaseStream() { _stream.Release(); } GetCRC()37 UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); } GetSize()38 UInt64 GetSize() const { return _size; } WasFinished()39 bool WasFinished() const { return _wasFinished; } 40 }; 41 42 43 Z7_CLASS_IMP_IInStream( 44 CInStreamWithCRC 45 ) 46 CMyComPtr<IInStream> _stream; 47 UInt64 _size; 48 UInt32 _crc; 49 // bool _wasFinished; 50 public: 51 void SetStream(IInStream *stream) { _stream = stream; } 52 void Init() 53 { 54 _size = 0; 55 // _wasFinished = false; 56 _crc = CRC_INIT_VAL; 57 } 58 void ReleaseStream() { _stream.Release(); } 59 UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); } 60 UInt64 GetSize() const { return _size; } 61 // bool WasFinished() const { return _wasFinished; } 62 }; 63 64 #endif 65