| OLD | NEW |
| (Empty) |
| 1 // LimitedStreams.h | |
| 2 | |
| 3 #ifndef __LIMITEDSTREAMS_H | |
| 4 #define __LIMITEDSTREAMS_H | |
| 5 | |
| 6 #include "../../Common/MyCom.h" | |
| 7 #include "../IStream.h" | |
| 8 | |
| 9 class CLimitedSequentialInStream: | |
| 10 public ISequentialInStream, | |
| 11 public CMyUnknownImp | |
| 12 { | |
| 13 CMyComPtr<ISequentialInStream> _stream; | |
| 14 UInt64 _size; | |
| 15 UInt64 _pos; | |
| 16 bool _wasFinished; | |
| 17 public: | |
| 18 void SetStream(ISequentialInStream *stream) { _stream = stream; } | |
| 19 void Init(UInt64 streamSize) | |
| 20 { | |
| 21 _size = streamSize; | |
| 22 _pos = 0; | |
| 23 _wasFinished = false; | |
| 24 } | |
| 25 | |
| 26 MY_UNKNOWN_IMP | |
| 27 | |
| 28 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); | |
| 29 UInt64 GetSize() const { return _pos; } | |
| 30 bool WasFinished() const { return _wasFinished; } | |
| 31 }; | |
| 32 | |
| 33 class CLimitedSequentialOutStream: | |
| 34 public ISequentialOutStream, | |
| 35 public CMyUnknownImp | |
| 36 { | |
| 37 CMyComPtr<ISequentialOutStream> _stream; | |
| 38 UInt64 _size; | |
| 39 bool _overflow; | |
| 40 public: | |
| 41 MY_UNKNOWN_IMP | |
| 42 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); | |
| 43 void SetStream(ISequentialOutStream *stream) { _stream = stream; } | |
| 44 void ReleaseStream() { _stream.Release(); } | |
| 45 void Init(UInt64 size) | |
| 46 { | |
| 47 _size = size; | |
| 48 _overflow = false; | |
| 49 } | |
| 50 bool IsFinishedOK() const { return (_size == 0 && !_overflow); } | |
| 51 UInt64 GetRem() const { return _size; } | |
| 52 }; | |
| 53 | |
| 54 #endif | |
| OLD | NEW |