misc/libphysfs/lzma/CPP/7zip/Common/LockedStream.cpp
author Wuzzy <Wuzzy2@mail.ru>
Mon, 03 Sep 2018 00:03:06 +0200
changeset 13743 d7b72ea8d136
parent 12213 bb5522e88ab2
permissions -rw-r--r--
Fix buggy behaviour when setting TurnTimeLeft through Retreat

// LockedStream.cpp

#include "StdAfx.h"

#include "LockedStream.h"

HRESULT CLockedInStream::Read(UInt64 startPos, void *data, UInt32 size, 
  UInt32 *processedSize)
{
  NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
  RINOK(_stream->Seek(startPos, STREAM_SEEK_SET, NULL));
  return _stream->Read(data, size, processedSize);
}

STDMETHODIMP CLockedSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize)
{
  UInt32 realProcessedSize = 0;
  HRESULT result = _lockedInStream->Read(_pos, data, size, &realProcessedSize);
  _pos += realProcessedSize;
  if (processedSize != NULL)
    *processedSize = realProcessedSize;
  return result;
}