diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-09-28 11:14:31 -0500 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-09-28 11:14:31 -0500 |
commit | b6967c8a9190efa4e9128850fa723fe3ea3140f7 (patch) | |
tree | 101be12055abd27968fce2666d573c80f8afe22d /include/fud_c_file.hpp | |
parent | 987466c74332025fae74d196ff680a57ccb247a2 (diff) |
Expand directory interface, remove FileStatus for FudStatus.
Diffstat (limited to 'include/fud_c_file.hpp')
-rw-r--r-- | include/fud_c_file.hpp | 53 |
1 files changed, 15 insertions, 38 deletions
diff --git a/include/fud_c_file.hpp b/include/fud_c_file.hpp index 674130c..9605ff0 100644 --- a/include/fud_c_file.hpp +++ b/include/fud_c_file.hpp @@ -18,6 +18,7 @@ #ifndef FUD_C_FILE_HPP #define FUD_C_FILE_HPP +#include "fud_status.hpp" #include "fud_result.hpp" #include "fud_string.hpp" @@ -77,64 +78,40 @@ constexpr const char* CTextFileModeFromFlags(CFileMode mode) } } -enum class FileStatus -{ - Success, - PartialSuccess, - InvalidName, - InvalidArgument, - InvalidState, - NullPointer, - Error, -}; - -static inline const char* FileStatusToString(FileStatus status) -{ - switch (status) { - case FileStatus::Success: - return "Success"; - case FileStatus::PartialSuccess: - return "PartialSuccess"; - case FileStatus::InvalidName: - return "InvalidName"; - case FileStatus::InvalidArgument: - return "InvalidArgument"; - case FileStatus::InvalidState: - return "InvalidState"; - case FileStatus::NullPointer: - return "NullPointer"; - case FileStatus::Error: - return "Error"; - default: - return "Unknown"; - } -} - struct [[nodiscard]] ReadResult { size_t bytesRead{0}; - FileStatus status{FileStatus::Success}; + FudStatus status{FudStatus::Success}; }; struct [[nodiscard]] WriteResult { size_t bytesWritten{0}; - FileStatus status{FileStatus::Success}; + FudStatus status{FudStatus::Success}; }; class CBinaryFile { public: CBinaryFile(const String& filename, CFileMode mode); + CBinaryFile(const String& filename, CFileMode mode, const String& extraFlags); + CBinaryFile(const CBinaryFile& rhs) = delete; + ~CBinaryFile(); + CBinaryFile& operator=(const CBinaryFile& rhs) = delete; - FileStatus open(); + + CBinaryFile& operator=(CBinaryFile&& rhs); + + FudStatus open(); + void close(); + const FILE* file() const; [[nodiscard]] FILE* file(); [[nodiscard]] bool isOpen() const; - [[nodiscard]] Result<size_t, FileStatus> size() const; + [[nodiscard]] Result<size_t, FudStatus> size() const; [[nodiscard]] ReadResult read(void* destination, size_t destinationSize, size_t length); @@ -179,7 +156,7 @@ class CBinaryFile { } private: - FileStatus reset() const; + FudStatus reset() const; const String m_filename; String m_extraFlags{}; |