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 #include "../../Windows/FileIO.h" 9 10 #include "../IStream.h" 11 12 class CInOutTempBuffer 13 { 14 NWindows::NFile::NDirectory::CTempFile _tempFile; 15 NWindows::NFile::NIO::COutFile _outFile; 16 Byte *_buf; 17 UInt32 _bufPos; 18 CSysString _tempFileName; 19 bool _tempFileCreated; 20 UInt64 _size; 21 UInt32 _crc; 22 23 bool WriteToFile(const void *data, UInt32 size); 24 public: 25 CInOutTempBuffer(); 26 ~CInOutTempBuffer(); 27 void Create(); 28 29 void InitWriting(); 30 bool Write(const void *data, UInt32 size); 31 32 HRESULT WriteToStream(ISequentialOutStream *stream); GetDataSize()33 UInt64 GetDataSize() const { return _size; } 34 }; 35 36 class CSequentialOutTempBufferImp: 37 public ISequentialOutStream, 38 public CMyUnknownImp 39 { 40 CInOutTempBuffer *_buf; 41 public: Init(CInOutTempBuffer * buffer)42 void Init(CInOutTempBuffer *buffer) { _buf = buffer; } 43 MY_UNKNOWN_IMP 44 45 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 46 }; 47 48 #endif 49