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: AuIOAdapterByteBuffer.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 "AuIOAdapterByteBuffer.hpp"
|
2022-06-11 23:01:27 +00:00
|
|
|
|
|
|
|
namespace Aurora::IO
|
|
|
|
{
|
2022-12-17 20:14:19 +00:00
|
|
|
AUKN_SYM AuSPtr<IStreamReader> NewByteBufferReadAdapter(const AuSPtr<Memory::ByteBuffer> &pBuffer)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
2022-12-17 20:14:19 +00:00
|
|
|
if (!pBuffer)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
|
|
|
SysPushErrorArg();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2022-12-17 20:14:19 +00:00
|
|
|
return AuMakeShared<Buffered::BlobReader>(pBuffer);
|
2022-06-11 23:01:27 +00:00
|
|
|
}
|
|
|
|
|
2022-12-17 20:14:19 +00:00
|
|
|
AUKN_SYM AuSPtr<ISeekingReader> NewByteBufferLinearSeekableAdapter(const AuSPtr<Memory::ByteBuffer> &pBuffer)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
2022-12-17 20:14:19 +00:00
|
|
|
if (!pBuffer)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
|
|
|
SysPushErrorArg();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2022-12-17 20:14:19 +00:00
|
|
|
if (pBuffer->flagCircular)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
|
|
|
SysPushErrorIO("Seekable buffer must not be circular");
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2022-12-17 20:14:19 +00:00
|
|
|
return AuMakeShared<Buffered::BlobSeekableReader>(pBuffer);
|
2022-06-11 23:01:27 +00:00
|
|
|
}
|
|
|
|
|
2022-12-17 20:14:19 +00:00
|
|
|
AUKN_SYM AuSPtr<IStreamWriter> NewByteBufferWriteAdapter(const AuSPtr<Memory::ByteBuffer> &pBuffer)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
2022-12-17 20:14:19 +00:00
|
|
|
if (!pBuffer)
|
2022-06-11 23:01:27 +00:00
|
|
|
{
|
|
|
|
SysPushErrorArg();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2022-12-17 20:14:19 +00:00
|
|
|
return AuMakeShared<Buffered::BlobWriter>(pBuffer);
|
2022-06-11 23:01:27 +00:00
|
|
|
}
|
|
|
|
}
|