misc/libphysfs/lzma/CPP/7zip/Common/StreamUtils.cpp
author antonc27 <antonc27@mail.ru>
Sun, 18 Mar 2018 18:47:03 +0100
branchios-develop
changeset 13250 195208deff1d
parent 12218 bb5522e88ab2
permissions -rw-r--r--
- Correct initialisation of TeamsGameOver (on mobile it doesn't get reset between plays, so ones set to true, prevents game to be finished next time)

// 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)
      return E_FAIL;
  }
  return S_OK;
}