1 // InOutTempBuffer.h 2 3 #ifndef __IN_OUT_TEMP_BUFFER_H 4 #define __IN_OUT_TEMP_BUFFER_H 5 6 #include "../../Common/MyCom.h" 7 #include "../../Windows/FileDir.h" 8 9 #include "../IStream.h" 10 11 class CInOutTempBuffer 12 { 13 NWindows::NFile::NDir::CTempFile _tempFile; 14 NWindows::NFile::NIO::COutFile _outFile; 15 Byte *_buf; 16 UInt32 _bufPos; 17 bool _tempFileCreated; 18 UInt64 _size; 19 UInt32 _crc; 20 21 bool WriteToFile(const void *data, UInt32 size); 22 public: 23 CInOutTempBuffer(); 24 ~CInOutTempBuffer(); 25 void Create(); 26 27 void InitWriting(); 28 bool Write(const void *data, UInt32 size); 29 30 HRESULT WriteToStream(ISequentialOutStream *stream); 31 UInt64 GetDataSize() const { return _size; } 32 }; 33 34 class CSequentialOutTempBufferImp: 35 public ISequentialOutStream, 36 public CMyUnknownImp 37 { 38 CInOutTempBuffer *_buf; 39 public: 40 void Init(CInOutTempBuffer *buffer) { _buf = buffer; } 41 MY_UNKNOWN_IMP 42 43 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 44 }; 45 46 #endif 47