other-licenses/7zstub/src/7zip/Common/StreamUtils.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // StreamUtils.cpp
     3 #include "StdAfx.h"
     5 #include "../../Common/MyCom.h"
     6 #include "StreamUtils.h"
     8 HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize)
     9 {
    10   if (processedSize != 0)
    11     *processedSize = 0;
    12   while(size != 0)
    13   {
    14     UInt32 processedSizeLoc; 
    15     HRESULT res = stream->Read(data, size, &processedSizeLoc);
    16     if (processedSize != 0)
    17       *processedSize += processedSizeLoc;
    18     data = (Byte *)((Byte *)data + processedSizeLoc);
    19     size -= processedSizeLoc;
    20     RINOK(res);
    21     if (processedSizeLoc == 0)
    22       return S_OK;
    23   }
    24   return S_OK;
    25 }
    27 HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize)
    28 {
    29   if (processedSize != 0)
    30     *processedSize = 0;
    31   while(size != 0)
    32   {
    33     UInt32 processedSizeLoc; 
    34     HRESULT res = stream->Write(data, size, &processedSizeLoc);
    35     if (processedSize != 0)
    36       *processedSize += processedSizeLoc;
    37     data = (const void *)((const Byte *)data + processedSizeLoc);
    38     size -= processedSizeLoc;
    39     RINOK(res);
    40     if (processedSizeLoc == 0)
    41       break;
    42   }
    43   return S_OK;
    44 }

mercurial