1 // InOutTempBuffer.h 2 3 #ifndef __IN_OUT_TEMP_BUFFER_H 4 #define __IN_OUT_TEMP_BUFFER_H 5 6 #ifdef _WIN32 7 // #define USE_InOutTempBuffer_FILE 8 #endif 9 10 #ifdef USE_InOutTempBuffer_FILE 11 #include "../../Windows/FileDir.h" 12 #else 13 #include "StreamObjects.h" 14 #endif 15 16 #include "../IStream.h" 17 18 class CInOutTempBuffer 19 { 20 #ifdef USE_InOutTempBuffer_FILE 21 22 NWindows::NFile::NDir::CTempFile _tempFile; 23 NWindows::NFile::NIO::COutFile _outFile; 24 bool _tempFileCreated; 25 Byte *_buf; 26 size_t _bufPos; 27 UInt64 _size; 28 UInt32 _crc; 29 30 #else 31 32 CByteDynBuffer _dynBuffer; 33 size_t _size; 34 35 #endif 36 37 CLASS_NO_COPY(CInOutTempBuffer); 38 public: 39 CInOutTempBuffer(); 40 void Create(); 41 42 #ifdef USE_InOutTempBuffer_FILE 43 ~CInOutTempBuffer(); 44 #endif 45 46 void InitWriting(); 47 HRESULT Write_HRESULT(const void *data, UInt32 size); 48 HRESULT WriteToStream(ISequentialOutStream *stream); GetDataSize()49 UInt64 GetDataSize() const { return _size; } 50 }; 51 52 /* 53 class CSequentialOutTempBufferImp: 54 public ISequentialOutStream, 55 public CMyUnknownImp 56 { 57 CInOutTempBuffer *_buf; 58 public: 59 void Init(CInOutTempBuffer *buffer) { _buf = buffer; } 60 MY_UNKNOWN_IMP 61 62 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 63 }; 64 */ 65 66 #endif 67