Welcome to mirror list, hosted at ThFree Co, Russian Federation.

LimitedStreams.cpp « Common « 7zip - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c048d49d2b1f665e92eafadaee2db19fa8093bbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// LimitedStreams.cpp

#include "StdAfx.h"

#include "LimitedStreams.h"
#include "../../Common/Defs.h"

void CLimitedSequentialInStream::Init(ISequentialInStream *stream, UInt64 streamSize)
{
  _stream = stream;
  _size = streamSize;
}

STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{
  UInt32 processedSizeReal;
  UInt32 sizeToRead = UInt32(MyMin(_size, UInt64(size)));
  HRESULT result = _stream->Read(data, sizeToRead, &processedSizeReal);
  _size -= processedSizeReal;
  if(processedSize != NULL)
    *processedSize = processedSizeReal;
  return result;
}