47 lines
990 B
Plaintext
47 lines
990 B
Plaintext
|
/***
|
||
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: IStreamReader.inl
|
||
|
Date: 2022-2-1
|
||
|
Author: Reece
|
||
|
***/
|
||
|
#pragma once
|
||
|
|
||
|
namespace Aurora::IO
|
||
|
{
|
||
|
EStreamError IStreamReader::ReadAll(Memory::ByteBuffer &buffer)
|
||
|
{
|
||
|
static const int kBufferSize = 2048;
|
||
|
|
||
|
AuUInt len;
|
||
|
EStreamError ret;
|
||
|
AuUInt8 temp[kBufferSize];
|
||
|
|
||
|
len = kBufferSize;
|
||
|
ret = EStreamError::eErrorEndOfStream;
|
||
|
|
||
|
buffer = Memory::NewResizableBuffer();
|
||
|
|
||
|
while ((ret = Read(Memory::MemoryViewStreamWrite(temp, len))) == EStreamError::eErrorNone)
|
||
|
{
|
||
|
if (len == 0)
|
||
|
{
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
buffer.Write(temp, len);
|
||
|
|
||
|
if (len != kBufferSize)
|
||
|
{
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (ret == EStreamError::eErrorEndOfStream)
|
||
|
{
|
||
|
return EStreamError::eErrorNone;
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
}
|
||
|
}
|