misc/libphysfs/lzma/CPP/7zip/Common/LimitedStreams.h
branchui-scaling
changeset 15283 c4fd2813b127
parent 13390 0135e64c6c66
parent 15279 7ab5cf405686
child 15663 d92eeb468dad
equal deleted inserted replaced
13390:0135e64c6c66 15283:c4fd2813b127
     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 #endif