From 0f1ae96ba4d737a578d0ded1188520d39c5e4d86 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Thu, 12 May 2016 21:44:37 -0700 Subject: [PATCH] Move File definition below std::filesystem. --- firmware/application/file.hpp | 80 +++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/firmware/application/file.hpp b/firmware/application/file.hpp index 56f9525d..789d2310 100644 --- a/firmware/application/file.hpp +++ b/firmware/application/file.hpp @@ -31,46 +31,6 @@ #include #include -class File { -public: - enum openmode { - app = 0x100, - binary = 0x200, - in = FA_READ, - out = FA_WRITE, - trunc = FA_CREATE_ALWAYS, - ate = FA_OPEN_ALWAYS, - }; - - File(const std::string& filename, openmode mode); - ~File(); - - bool is_open() const { - return f_error(&f) == 0; - } - - bool read(void* const data, const size_t bytes_to_read); - bool write(const void* const data, const size_t bytes_to_write); - - uint64_t seek(const uint64_t new_position); - - template - bool write(const std::array& data) { - return write(data.data(), N); - } - - bool puts(const std::string& string); - - bool sync(); - -private: - FIL f; -}; - -inline constexpr File::openmode operator|(File::openmode a, File::openmode b) { - return File::openmode(static_cast(a) | static_cast(b)); -} - std::string next_filename_stem_matching_pattern(const std::string& filename_stem_pattern); namespace std { @@ -151,4 +111,44 @@ space_info space(const path& p); } /* namespace filesystem */ } /* namespace std */ +class File { +public: + enum openmode { + app = 0x100, + binary = 0x200, + in = FA_READ, + out = FA_WRITE, + trunc = FA_CREATE_ALWAYS, + ate = FA_OPEN_ALWAYS, + }; + + File(const std::string& filename, openmode mode); + ~File(); + + bool is_open() const { + return f_error(&f) == 0; + } + + bool read(void* const data, const size_t bytes_to_read); + bool write(const void* const data, const size_t bytes_to_write); + + uint64_t seek(const uint64_t new_position); + + template + bool write(const std::array& data) { + return write(data.data(), N); + } + + bool puts(const std::string& string); + + bool sync(); + +private: + FIL f; +}; + +inline constexpr File::openmode operator|(File::openmode a, File::openmode b) { + return File::openmode(static_cast(a) | static_cast(b)); +} + #endif/*__FILE_H__*/