diff --git a/firmware/application/file.cpp b/firmware/application/file.cpp index ff523de8..18e75005 100644 --- a/firmware/application/file.cpp +++ b/firmware/application/file.cpp @@ -63,6 +63,17 @@ bool File::write(const void* const data, const size_t bytes_to_write) { return (result == FR_OK) && (bytes_written == bytes_to_write); } +uint64_t File::seek(const uint64_t new_position) { + const auto old_position = f_tell(&f); + if( f_lseek(&f, new_position) != FR_OK ) { + f_close(&f); + } + if( f_tell(&f) != new_position ) { + f_close(&f); + } + return old_position; +} + bool File::puts(const std::string& string) { const auto result = f_puts(string.c_str(), &f); return (result >= 0); diff --git a/firmware/application/file.hpp b/firmware/application/file.hpp index b4b0c74f..6be0f9dd 100644 --- a/firmware/application/file.hpp +++ b/firmware/application/file.hpp @@ -51,6 +51,8 @@ public: 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);