From 87505f833b467d619099ea172f6f9b1510a84693 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Thu, 12 May 2016 21:57:38 -0700 Subject: [PATCH] Expose filesystem errors on Writer. --- firmware/application/capture_thread.hpp | 4 ++++ firmware/application/ui_record_view.cpp | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/firmware/application/capture_thread.hpp b/firmware/application/capture_thread.hpp index 5ebd4944..a8e5bb3e 100644 --- a/firmware/application/capture_thread.hpp +++ b/firmware/application/capture_thread.hpp @@ -26,6 +26,9 @@ #include "event_m0.hpp" +#include "file.hpp" +#include "optional.hpp" + #include #include #include @@ -33,6 +36,7 @@ class Writer { public: virtual bool write(const void* const buffer, const size_t bytes) = 0; + virtual Optional error() const = 0; virtual ~Writer() = default; }; diff --git a/firmware/application/ui_record_view.cpp b/firmware/application/ui_record_view.cpp index 5e813a90..0eb67bc7 100644 --- a/firmware/application/ui_record_view.cpp +++ b/firmware/application/ui_record_view.cpp @@ -44,6 +44,14 @@ public: return file.write(buffer, bytes); } + Optional error() const override { + if( file.bad() ) { + return { file.error() }; + } else { + return { }; + } + } + private: File file; }; @@ -71,6 +79,14 @@ public: return success; } + Optional error() const override { + if( file.bad() ) { + return { file.error() }; + } else { + return { }; + } + } + private: struct fmt_pcm_t { constexpr fmt_pcm_t(