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