diff options
author | root <root@lamia.panaceas.james.local> | 2015-12-19 14:18:43 +0000 |
---|---|---|
committer | root <root@lamia.panaceas.james.local> | 2015-12-19 14:18:43 +0000 |
commit | 71478fd62d8483483abb34609cdabb7f9cbadfd6 (patch) | |
tree | 37b8eaba1ffe2d5f775227911eb0ed6fdc3c9553 /hostTools/lzma/compress/OutByte.cpp | |
parent | 1a2238d1bddc823df06f67312d96ccf9de2893cc (diff) | |
download | bootloader-71478fd62d8483483abb34609cdabb7f9cbadfd6.tar.gz bootloader-71478fd62d8483483abb34609cdabb7f9cbadfd6.tar.bz2 bootloader-71478fd62d8483483abb34609cdabb7f9cbadfd6.zip |
Add hostTools from https://github.com/Noltari/cfe_bcm63xx
Diffstat (limited to 'hostTools/lzma/compress/OutByte.cpp')
-rw-r--r-- | hostTools/lzma/compress/OutByte.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/hostTools/lzma/compress/OutByte.cpp b/hostTools/lzma/compress/OutByte.cpp new file mode 100644 index 0000000..a658798 --- /dev/null +++ b/hostTools/lzma/compress/OutByte.cpp @@ -0,0 +1,45 @@ +#include "OutByte.h" + +namespace NStream { + +COutByte::COutByte(UINT32 aBufferSize): + m_BufferSize(aBufferSize) +{ + m_Buffer = new BYTE[m_BufferSize]; +} + +COutByte::~COutByte() +{ + delete []m_Buffer; +} + +void COutByte::Init(ISequentialOutStream *aStream) +{ + m_Stream = aStream; + m_ProcessedSize = 0; + m_Pos = 0; +} + +HRESULT COutByte::Flush() +{ + if (m_Pos == 0) + return S_OK; + UINT32 aProcessedSize; + HRESULT aResult = m_Stream->Write(m_Buffer, m_Pos, &aProcessedSize); + if (aResult != S_OK) + return aResult; + if (m_Pos != aProcessedSize) + return E_FAIL; + m_ProcessedSize += aProcessedSize; + m_Pos = 0; + return S_OK; +} + +void COutByte::WriteBlock() +{ + HRESULT aResult = Flush(); + if (aResult != S_OK) + throw aResult; +} + +} |