feat: add streams
All checks were successful
Linux arm64 / Build (push) Successful in 16s

This commit is contained in:
2025-06-26 19:17:52 +02:00
parent 59bedd6482
commit 0d26879152
25 changed files with 385 additions and 778 deletions

View File

@@ -1,31 +0,0 @@
#include <sp/io/File.h>
namespace sp {
namespace io {
File::IOInterface(const std::string& a_FilePath, unsigned int a_OpenMode) {
if (a_OpenMode & FileTag::OpenMode::In)
m_FileInput = std::make_unique<std::ifstream>(a_FilePath, std::ios::binary);
if (a_OpenMode & FileTag::OpenMode::Out)
m_FileOutput = std::make_unique<std::ofstream>(a_FilePath, std::ios::binary);
}
File::IOInterface(File&& other) :
m_FileInput(std::move(other.m_FileInput)), m_FileOutput(std::move(other.m_FileOutput)) {}
DataBuffer File::Read(std::size_t a_Amount) {
DataBuffer buffer;
buffer.Resize(a_Amount);
assert(m_FileInput != nullptr);
m_FileInput->read(reinterpret_cast<char*>(buffer.data()), a_Amount);
return buffer;
}
void File::Write(const sp::DataBuffer& a_Data) {
assert(m_FileOutput != nullptr);
m_FileOutput->write(reinterpret_cast<const char*>(a_Data.data()), a_Data.GetSize());
m_FileOutput->flush();
}
} // namespace io
} // namespace sp