diff options
Diffstat (limited to '7zip/Common/OutBuffer.h')
-rwxr-xr-x | 7zip/Common/OutBuffer.h | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/7zip/Common/OutBuffer.h b/7zip/Common/OutBuffer.h index b161ad65..51ccb659 100755 --- a/7zip/Common/OutBuffer.h +++ b/7zip/Common/OutBuffer.h @@ -16,48 +16,40 @@ struct COutBufferException class COutBuffer { +protected: Byte *_buffer; UInt32 _pos; + UInt32 _limitPos; + UInt32 _streamPos; UInt32 _bufferSize; CMyComPtr<ISequentialOutStream> _stream; UInt64 _processedSize; + Byte *_buffer2; - void WriteBlock(); + HRESULT FlushPart(); + void FlushWithCheck(); public: #ifdef _NO_EXCEPTIONS HRESULT ErrorCode; #endif - COutBuffer(): _buffer(0), _pos(0), _stream(0) {} + COutBuffer(): _buffer(0), _pos(0), _stream(0), _buffer2(0) {} ~COutBuffer() { Free(); } bool Create(UInt32 bufferSize); void Free(); + void SetMemStream(Byte *buffer) { _buffer2 = buffer; } void SetStream(ISequentialOutStream *stream); void Init(); HRESULT Flush(); void ReleaseStream() { _stream.Release(); } - /* - void *GetBuffer(UInt32 &sizeAvail) - { - sizeAvail = _bufferSize - _pos; - return _buffer + _pos; - } - void MovePos(UInt32 num) - { - _pos += num; - if(_pos >= _bufferSize) - WriteBlock(); - } - */ - void WriteByte(Byte b) { _buffer[_pos++] = b; - if(_pos >= _bufferSize) - WriteBlock(); + if(_pos == _limitPos) + FlushWithCheck(); } void WriteBytes(const void *data, size_t size) { @@ -65,7 +57,7 @@ public: WriteByte(((const Byte *)data)[i]); } - UInt64 GetProcessedSize() const { return _processedSize + _pos; } + UInt64 GetProcessedSize() const; }; #endif |