michael@0: // StreamUtils.cpp michael@0: michael@0: #include "StdAfx.h" michael@0: michael@0: #include "../../Common/MyCom.h" michael@0: #include "StreamUtils.h" michael@0: michael@0: HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize) michael@0: { michael@0: if (processedSize != 0) michael@0: *processedSize = 0; michael@0: while(size != 0) michael@0: { michael@0: UInt32 processedSizeLoc; michael@0: HRESULT res = stream->Read(data, size, &processedSizeLoc); michael@0: if (processedSize != 0) michael@0: *processedSize += processedSizeLoc; michael@0: data = (Byte *)((Byte *)data + processedSizeLoc); michael@0: size -= processedSizeLoc; michael@0: RINOK(res); michael@0: if (processedSizeLoc == 0) michael@0: return S_OK; michael@0: } michael@0: return S_OK; michael@0: } michael@0: michael@0: HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize) michael@0: { michael@0: if (processedSize != 0) michael@0: *processedSize = 0; michael@0: while(size != 0) michael@0: { michael@0: UInt32 processedSizeLoc; michael@0: HRESULT res = stream->Write(data, size, &processedSizeLoc); michael@0: if (processedSize != 0) michael@0: *processedSize += processedSizeLoc; michael@0: data = (const void *)((const Byte *)data + processedSizeLoc); michael@0: size -= processedSizeLoc; michael@0: RINOK(res); michael@0: if (processedSizeLoc == 0) michael@0: break; michael@0: } michael@0: return S_OK; michael@0: }