47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
/***
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: AuIOAdapterSeeking.cpp
|
|
Date: 2022-6-6
|
|
Author: Reece
|
|
***/
|
|
#include <Source/RuntimeInternal.hpp>
|
|
#include <Aurora/IO/IOExperimental.hpp>
|
|
#include "AuIOAdapterSeeking.hpp"
|
|
|
|
namespace Aurora::IO::Adapters
|
|
{
|
|
SeekingReader::SeekingReader(const AuSPtr<ISeekingReader> &pReader) :
|
|
pReader(pReader)
|
|
{
|
|
|
|
}
|
|
|
|
EStreamError SeekingReader::IsOpen()
|
|
{
|
|
return this->pReader ? this->pReader->IsOpen() : EStreamError::eErrorStreamNotOpen;
|
|
}
|
|
|
|
EStreamError SeekingReader::Read(const Memory::MemoryViewStreamWrite ¶meters)
|
|
{
|
|
auto error = this->pReader ? this->pReader->ArbitraryRead(this->uIndex, parameters) : EStreamError::eErrorStreamNotOpen;
|
|
if (error == EStreamError::eErrorNone)
|
|
{
|
|
this->uIndex += parameters.outVariable;
|
|
}
|
|
return error;
|
|
}
|
|
|
|
void SeekingReader::Close()
|
|
{
|
|
if (this->pReader)
|
|
{
|
|
this->pReader->Close();
|
|
}
|
|
}
|
|
|
|
AUKN_SYM AuSPtr<IStreamReader> NewSeekingReadAdapter(const AuSPtr<ISeekingReader> &pReader)
|
|
{
|
|
return AuMakeShared<SeekingReader>(pReader);
|
|
}
|
|
} |