Mercurial > vba-linux
diff src/win32/7zip/7z/CPP/7zip/Common/LimitedStreams.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Common/LimitedStreams.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,54 @@ 1.4 +// LimitedStreams.h 1.5 + 1.6 +#ifndef __LIMITEDSTREAMS_H 1.7 +#define __LIMITEDSTREAMS_H 1.8 + 1.9 +#include "../../Common/MyCom.h" 1.10 +#include "../IStream.h" 1.11 + 1.12 +class CLimitedSequentialInStream: 1.13 + public ISequentialInStream, 1.14 + public CMyUnknownImp 1.15 +{ 1.16 + CMyComPtr<ISequentialInStream> _stream; 1.17 + UInt64 _size; 1.18 + UInt64 _pos; 1.19 + bool _wasFinished; 1.20 +public: 1.21 + void SetStream(ISequentialInStream *stream) { _stream = stream; } 1.22 + void Init(UInt64 streamSize) 1.23 + { 1.24 + _size = streamSize; 1.25 + _pos = 0; 1.26 + _wasFinished = false; 1.27 + } 1.28 + 1.29 + MY_UNKNOWN_IMP 1.30 + 1.31 + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 1.32 + UInt64 GetSize() const { return _pos; } 1.33 + bool WasFinished() const { return _wasFinished; } 1.34 +}; 1.35 + 1.36 +class CLimitedSequentialOutStream: 1.37 + public ISequentialOutStream, 1.38 + public CMyUnknownImp 1.39 +{ 1.40 + CMyComPtr<ISequentialOutStream> _stream; 1.41 + UInt64 _size; 1.42 + bool _overflow; 1.43 +public: 1.44 + MY_UNKNOWN_IMP 1.45 + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 1.46 + void SetStream(ISequentialOutStream *stream) { _stream = stream; } 1.47 + void ReleaseStream() { _stream.Release(); } 1.48 + void Init(UInt64 size) 1.49 + { 1.50 + _size = size; 1.51 + _overflow = false; 1.52 + } 1.53 + bool IsFinishedOK() const { return (_size == 0 && !_overflow); } 1.54 + UInt64 GetRem() const { return _size; } 1.55 +}; 1.56 + 1.57 +#endif