diff options
author | rtk0c <[email protected]> | 2022-06-30 21:38:53 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-06-30 21:38:53 -0700 |
commit | 7fe47a9d5b1727a61dc724523b530762f6d6ba19 (patch) | |
tree | e95be6e66db504ed06d00b72c579565bab873277 /core/src/Utils/IO/FileStream_Cstdio.inl | |
parent | 2cf952088d375ac8b2f45b144462af0953436cff (diff) |
Restructure project
Diffstat (limited to 'core/src/Utils/IO/FileStream_Cstdio.inl')
-rw-r--r-- | core/src/Utils/IO/FileStream_Cstdio.inl | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/core/src/Utils/IO/FileStream_Cstdio.inl b/core/src/Utils/IO/FileStream_Cstdio.inl deleted file mode 100644 index ee55681..0000000 --- a/core/src/Utils/IO/FileStream_Cstdio.inl +++ /dev/null @@ -1,126 +0,0 @@ -// Note: included by FileStream.cpp conditionally, not compiled separately -#include "FileStream.hpp" - -#include "Utils/IO/CstdioFile.hpp" - -#include <cstdio> -#include <filesystem> - -namespace fs = std::filesystem; - -InputFileStream::InputFileStream(const fs::path& path) - : mFile{ FileUtils::OpenCstdioFile(path, FileUtils::IM_Read) } -{ -} - -InputFileStream::~InputFileStream() -{ - if (mFile) { - std::fclose(mFile); - } -} - -InputFileStream::InputFileStream(InputFileStream&& that) - : mFile{ that.mFile } -{ - that.mFile = nullptr; -} - -InputFileStream& InputFileStream::operator=(InputFileStream&& that) -{ - if (this == &that) return *this; - - if (mFile) { - std::fclose(mFile); - } - mFile = that.mFile; - that.mFile = nullptr; - - return *this; -} - -OutputFileStream::OutputFileStream(const fs::path& path, WriteMode mode) -{ - switch (mode) { - case AppendFile: mFile = FileUtils::OpenCstdioFile(path, FileUtils::IM_WriteAppend); break; - case TruncateFile: mFile = FileUtils::OpenCstdioFile(path, FileUtils::IM_WriteTruncate); break; - } -} - -OutputFileStream::~OutputFileStream() -{ - if (mFile) { - std::fclose(mFile); - } -} - -OutputFileStream::OutputFileStream(OutputFileStream&& that) - : mFile{ that.mFile } -{ - that.mFile = nullptr; -} - -OutputFileStream& OutputFileStream::operator=(OutputFileStream&& that) -{ - if (this == &that) return *this; - - if (mFile) { - std::fclose(mFile); - } - mFile = that.mFile; - that.mFile = nullptr; - - return *this; -} - -int InputFileStream::GetReadInSize() const -{ - return 0; -} - -void InputFileStream::SetReadInSize(int size) -{ - // No-op -} - -bool InputFileStream::IsEof() const -{ - return std::feof(mFile); -} - -IoResult InputFileStream::ReadBytes(size_t bufferLength, std::byte* buffer) -{ - auto bytesRead = std::fread(buffer, 1, bufferLength, mFile); - - return { - .Error = IoResult::ERR_None, - .SystemError = 0, - .BytesMoved = bytesRead, - }; -} - -int OutputFileStream::GetMaxBufferSize() const -{ - return 0; -} - -void OutputFileStream::SetMaxBufferSize(int maxSize) -{ - // No-op -} - -IoResult OutputFileStream::WriteBytes(size_t bufferLength, const std::byte* buffer) -{ - auto bytesWritten = std::fwrite(buffer, 1, bufferLength, mFile); - - return IoResult{ - .Error = IoResult::ERR_None, - .SystemError = 0, - .BytesMoved = bytesWritten, - }; -} - -void OutputFileStream::FlushBuffer() -{ - // No-op -} |