diff --git a/firmware/application/capture_thread.hpp b/firmware/application/capture_thread.hpp index 849a3131..6e2bbaa8 100644 --- a/firmware/application/capture_thread.hpp +++ b/firmware/application/capture_thread.hpp @@ -35,7 +35,7 @@ class Writer { public: - virtual File::Result write(const void* const buffer, const size_t bytes) = 0; + virtual File::Result write(const void* const buffer, const File::Size bytes) = 0; virtual ~Writer() = default; }; diff --git a/firmware/application/file.cpp b/firmware/application/file.cpp index 4ceb51aa..8c45c8b3 100644 --- a/firmware/application/file.cpp +++ b/firmware/application/file.cpp @@ -64,7 +64,7 @@ File::~File() { f_close(&f); } -File::Result File::read(void* const data, const size_t bytes_to_read) { +File::Result File::read(void* const data, const Size bytes_to_read) { UINT bytes_read = 0; const auto result = f_read(&f, data, bytes_to_read, &bytes_read); if( result == FR_OK ) { @@ -74,12 +74,12 @@ File::Result File::read(void* const data, const size_t bytes_to_read) { } } -File::Result File::write(const void* const data, const size_t bytes_to_write) { +File::Result File::write(const void* const data, const Size bytes_to_write) { UINT bytes_written = 0; const auto result = f_write(&f, data, bytes_to_write, &bytes_written); if( result == FR_OK ) { if( bytes_to_write == bytes_written ) { - return { static_cast(bytes_written) }; + return { static_cast(bytes_written) }; } else { return Error { FR_DISK_FULL }; } @@ -88,7 +88,7 @@ File::Result File::write(const void* const data, const size_t bytes_to_w } } -File::Result File::seek(const uint64_t new_position) { +File::Result File::seek(const Offset new_position) { /* NOTE: Returns *old* position, not new position */ const auto old_position = f_tell(&f); const auto result = f_lseek(&f, new_position); @@ -98,7 +98,7 @@ File::Result File::seek(const uint64_t new_position) { if( f_tell(&f) != new_position ) { return { static_cast(FR_BAD_SEEK) }; } - return { static_cast(old_position) }; + return { static_cast(old_position) }; } Optional File::write_line(const std::string& s) { diff --git a/firmware/application/file.hpp b/firmware/application/file.hpp index 62813e21..64691703 100644 --- a/firmware/application/file.hpp +++ b/firmware/application/file.hpp @@ -136,6 +136,8 @@ std::filesystem::path next_filename_stem_matching_pattern(const std::filesystem: class File { public: + using Size = uint64_t; + using Offset = uint64_t; using Error = std::filesystem::filesystem_error; template @@ -200,13 +202,13 @@ public: Optional append(const std::filesystem::path& filename); Optional create(const std::filesystem::path& filename); - Result read(void* const data, const size_t bytes_to_read); - Result write(const void* const data, const size_t bytes_to_write); + Result read(void* const data, const Size bytes_to_read); + Result write(const void* const data, const Size bytes_to_write); - Result seek(const uint64_t new_position); + Result seek(const uint64_t Offset); template - Result write(const std::array& data) { + Result write(const std::array& data) { return write(data.data(), N); } diff --git a/firmware/application/ui_record_view.cpp b/firmware/application/ui_record_view.cpp index 42e0d374..71211dfc 100644 --- a/firmware/application/ui_record_view.cpp +++ b/firmware/application/ui_record_view.cpp @@ -48,7 +48,7 @@ public: return file.create(filename); } - File::Result write(const void* const buffer, const size_t bytes) override { + File::Result write(const void* const buffer, const File::Size bytes) override { auto write_result = file.write(buffer, bytes) ; if( write_result.is_ok() ) { bytes_written += write_result.value(); diff --git a/firmware/application/ui_sd_card_debug.cpp b/firmware/application/ui_sd_card_debug.cpp index dd92f5c6..856f3e63 100644 --- a/firmware/application/ui_sd_card_debug.cpp +++ b/firmware/application/ui_sd_card_debug.cpp @@ -51,13 +51,13 @@ public: halrtcnt_t write_duration_min { 0 }; halrtcnt_t write_duration_max { 0 }; halrtcnt_t write_test_duration { 0 }; - size_t write_bytes { 0 }; + File::Size write_bytes { 0 }; size_t write_count { 0 }; halrtcnt_t read_duration_min { 0 }; halrtcnt_t read_duration_max { 0 }; halrtcnt_t read_test_duration { 0 }; - size_t read_bytes { 0 }; + File::Size read_bytes { 0 }; size_t read_count { 0 }; }; @@ -80,9 +80,9 @@ public: } private: - static constexpr size_t write_size = 16384; - static constexpr size_t bytes_to_write = 16 * 1024 * 1024; - static constexpr size_t bytes_to_read = bytes_to_write; + static constexpr File::Size write_size = 16384; + static constexpr File::Size bytes_to_write = 16 * 1024 * 1024; + static constexpr File::Size bytes_to_read = bytes_to_write; static Thread* thread; volatile Result _result { Result::Incomplete }; @@ -365,7 +365,7 @@ static std::string format_ticks_as_ms(const halrtcnt_t value) { return format_3dot3_string(us); } -static std::string format_bytes_per_ticks_as_mib(const size_t bytes, const halrtcnt_t ticks) { +static std::string format_bytes_per_ticks_as_mib(const File::Size bytes, const halrtcnt_t ticks) { const uint32_t bps = uint64_t(bytes) * halGetCounterFrequency() / ticks; const uint32_t kbps = bps / 1000U; return format_3dot3_string(kbps);