michael@0: // Util/InOutTempBuffer.h michael@0: michael@0: #ifndef __IN_OUT_TEMP_BUFFER_H michael@0: #define __IN_OUT_TEMP_BUFFER_H michael@0: michael@0: #include "../../Windows/FileIO.h" michael@0: #include "../../Windows/FileDir.h" michael@0: #include "../../Common/MyCom.h" michael@0: michael@0: #include "../IStream.h" michael@0: michael@0: class CInOutTempBuffer michael@0: { michael@0: NWindows::NFile::NDirectory::CTempFile _tempFile; michael@0: NWindows::NFile::NIO::COutFile _outFile; michael@0: NWindows::NFile::NIO::CInFile _inFile; michael@0: Byte *_buffer; michael@0: UInt32 _bufferPosition; michael@0: UInt32 _currentPositionInBuffer; michael@0: CSysString _tmpFileName; michael@0: bool _tmpFileCreated; michael@0: michael@0: UInt64 _fileSize; michael@0: michael@0: bool WriteToFile(const void *data, UInt32 size); michael@0: public: michael@0: CInOutTempBuffer(); michael@0: ~CInOutTempBuffer(); michael@0: void Create(); michael@0: michael@0: void InitWriting(); michael@0: bool Write(const void *data, UInt32 size); michael@0: UInt64 GetDataSize() const { return _fileSize; } michael@0: bool FlushWrite(); michael@0: bool InitReading(); michael@0: HRESULT WriteToStream(ISequentialOutStream *stream); michael@0: }; michael@0: michael@0: class CSequentialOutTempBufferImp: michael@0: public ISequentialOutStream, michael@0: public CMyUnknownImp michael@0: { michael@0: CInOutTempBuffer *_buffer; michael@0: public: michael@0: // CSequentialOutStreamImp(): _size(0) {} michael@0: // UInt32 _size; michael@0: void Init(CInOutTempBuffer *buffer) { _buffer = buffer; } michael@0: // UInt32 GetSize() const { return _size; } michael@0: michael@0: MY_UNKNOWN_IMP michael@0: michael@0: STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); michael@0: }; michael@0: michael@0: #endif