Mercurial > vba-linux
view src/win32/7zip/7z/CPP/7zip/Common/StreamObjects.cpp @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line source
1 // StreamObjects.cpp3 #include "StdAfx.h"5 #include "StreamObjects.h"6 #include "../../Common/Defs.h"9 STDMETHODIMP CSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize)10 {11 size_t rem = _size - _pos;12 if (size < rem)13 rem = (size_t)size;14 memcpy(data, _dataPointer + _pos, rem);15 _pos += rem;16 if (processedSize != NULL)17 *processedSize = (UInt32)rem;18 return S_OK;19 }22 void CWriteBuffer::Write(const void *data, size_t size)23 {24 size_t newCapacity = _size + size;25 _buffer.EnsureCapacity(newCapacity);26 memcpy(_buffer + _size, data, size);27 _size += size;28 }30 STDMETHODIMP CSequentialOutStreamImp::Write(const void *data, UInt32 size, UInt32 *processedSize)31 {32 _writeBuffer.Write(data, (size_t)size);33 if(processedSize != NULL)34 *processedSize = size;35 return S_OK;36 }38 STDMETHODIMP CSequentialOutStreamImp2::Write(const void *data, UInt32 size, UInt32 *processedSize)39 {40 size_t rem = _size - _pos;41 if (size < rem)42 rem = (size_t)size;43 memcpy(_buffer + _pos, data, rem);44 _pos += rem;45 if (processedSize != NULL)46 *processedSize = (UInt32)rem;47 return (rem == size ? S_OK : E_FAIL);48 }50 STDMETHODIMP CSequentialInStreamSizeCount::Read(void *data, UInt32 size, UInt32 *processedSize)51 {52 UInt32 realProcessedSize;53 HRESULT result = _stream->Read(data, size, &realProcessedSize);54 _size += realProcessedSize;55 if (processedSize != 0)56 *processedSize = realProcessedSize;57 return result;58 }60 STDMETHODIMP CSequentialOutStreamSizeCount::Write(const void *data, UInt32 size, UInt32 *processedSize)61 {62 UInt32 realProcessedSize;63 HRESULT result = _stream->Write(data, size, &realProcessedSize);64 _size += realProcessedSize;65 if (processedSize != 0)66 *processedSize = realProcessedSize;67 return result;68 }