mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-12 20:11:34 -06:00
3.13
This commit is contained in:
53
7zip/Common/OutBuffer.cpp
Executable file
53
7zip/Common/OutBuffer.cpp
Executable file
@@ -0,0 +1,53 @@
|
||||
// Stream/OutByte.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "OutBuffer.h"
|
||||
|
||||
COutBuffer::COutBuffer(UINT32 bufferSize):
|
||||
_bufferSize(bufferSize)
|
||||
{
|
||||
_buffer = new BYTE[_bufferSize];
|
||||
}
|
||||
|
||||
COutBuffer::~COutBuffer()
|
||||
{
|
||||
delete []_buffer;
|
||||
}
|
||||
|
||||
void COutBuffer::Init(ISequentialOutStream *stream)
|
||||
{
|
||||
_stream = stream;
|
||||
_processedSize = 0;
|
||||
_pos = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
void COutBuffer::ReleaseStream()
|
||||
{
|
||||
_stream.Release();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
HRESULT COutBuffer::Flush()
|
||||
{
|
||||
if (_pos == 0)
|
||||
return S_OK;
|
||||
UINT32 processedSize;
|
||||
HRESULT result = _stream->Write(_buffer, _pos, &processedSize);
|
||||
if (result != S_OK)
|
||||
return result;
|
||||
if (_pos != processedSize)
|
||||
return E_FAIL;
|
||||
_processedSize += processedSize;
|
||||
_pos = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void COutBuffer::WriteBlock()
|
||||
{
|
||||
HRESULT result = Flush();
|
||||
if (result != S_OK)
|
||||
throw COutBufferException(result);
|
||||
}
|
||||
Reference in New Issue
Block a user