From 0a9d7ec8d8b234fc405438b233d1c8a8951c80ac Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sun, 10 Apr 2016 15:56:34 -0700 Subject: [PATCH] Add File::open_for_reading(). Barf. --- firmware/application/file.cpp | 5 +++++ firmware/application/file.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/firmware/application/file.cpp b/firmware/application/file.cpp index 0ea0f57e..a14325e0 100644 --- a/firmware/application/file.cpp +++ b/firmware/application/file.cpp @@ -30,6 +30,11 @@ bool File::open_for_writing(const std::string& file_path) { return (open_result == FR_OK); } +bool File::open_for_reading(const std::string& file_path) { + const auto open_result = f_open(&f, file_path.c_str(), FA_READ | FA_OPEN_EXISTING); + return (open_result == FR_OK); +} + bool File::open_for_append(const std::string& file_path) { if( open_for_writing(file_path) ) { const auto seek_result = f_lseek(&f, f_size(&f)); diff --git a/firmware/application/file.hpp b/firmware/application/file.hpp index df391db7..5a4524cf 100644 --- a/firmware/application/file.hpp +++ b/firmware/application/file.hpp @@ -33,6 +33,7 @@ public: ~File(); bool open_for_writing(const std::string& file_path); + bool open_for_reading(const std::string& file_path); bool open_for_append(const std::string& file_path); bool close();