LimitedStreams.h 694 B

12345678910111213141516171819202122232425262728293031323334
  1. // LimitedStreams.h
  2. #ifndef __LIMITEDSTREAMS_H
  3. #define __LIMITEDSTREAMS_H
  4. #include "../../Common/MyCom.h"
  5. #include "../IStream.h"
  6. class CLimitedSequentialInStream:
  7. public ISequentialInStream,
  8. public CMyUnknownImp
  9. {
  10. CMyComPtr<ISequentialInStream> _stream;
  11. UInt64 _size;
  12. UInt64 _pos;
  13. bool _wasFinished;
  14. public:
  15. void SetStream(ISequentialInStream *stream) { _stream = stream; }
  16. void Init(UInt64 streamSize)
  17. {
  18. _size = streamSize;
  19. _pos = 0;
  20. _wasFinished = false;
  21. }
  22. MY_UNKNOWN_IMP
  23. STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  24. UInt64 GetSize() const { return _pos; }
  25. bool WasFinished() const { return _wasFinished; }
  26. };
  27. #endif