misc/libphysfs/lzma/CPP/7zip/Common/LimitedStreams.h
changeset 13904 99b265e0d1d0
parent 13903 5f819b90d479
child 13905 b172a5d40eee
equal deleted inserted replaced
13903:5f819b90d479 13904:99b265e0d1d0
     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