mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-13 16:11:34 -06:00
4.27 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
31e7b924e8
commit
d66cf2fcf3
44
7zip/Common/StreamUtils.cpp
Executable file
44
7zip/Common/StreamUtils.cpp
Executable file
@@ -0,0 +1,44 @@
|
||||
// StreamUtils.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/MyCom.h"
|
||||
#include "StreamUtils.h"
|
||||
|
||||
HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
if (processedSize != 0)
|
||||
*processedSize = 0;
|
||||
while(size != 0)
|
||||
{
|
||||
UInt32 processedSizeLoc;
|
||||
HRESULT res = stream->Read(data, size, &processedSizeLoc);
|
||||
if (processedSize != 0)
|
||||
*processedSize += processedSizeLoc;
|
||||
data = (Byte *)((Byte *)data + processedSizeLoc);
|
||||
size -= processedSizeLoc;
|
||||
RINOK(res);
|
||||
if (processedSizeLoc == 0)
|
||||
return S_OK;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
if (processedSize != 0)
|
||||
*processedSize = 0;
|
||||
while(size != 0)
|
||||
{
|
||||
UInt32 processedSizeLoc;
|
||||
HRESULT res = stream->Write(data, size, &processedSizeLoc);
|
||||
if (processedSize != 0)
|
||||
*processedSize += processedSizeLoc;
|
||||
data = (const void *)((const Byte *)data + processedSizeLoc);
|
||||
size -= processedSizeLoc;
|
||||
RINOK(res);
|
||||
if (processedSizeLoc == 0)
|
||||
break;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
Reference in New Issue
Block a user