From 79553ab1fa3d707612e80dd03bf95ca65fa0c411 Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Tue, 4 Feb 2025 23:11:08 +0100 Subject: refactor file browser --- app/mac/impl/file-browser-posix.hh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 app/mac/impl/file-browser-posix.hh (limited to 'app/mac/impl/file-browser-posix.hh') diff --git a/app/mac/impl/file-browser-posix.hh b/app/mac/impl/file-browser-posix.hh new file mode 100644 index 0000000..b760e53 --- /dev/null +++ b/app/mac/impl/file-browser-posix.hh @@ -0,0 +1,30 @@ +#pragma once + +#include "nes/app/file-browser.hh" +#include "nes/common/path-builder.hh" +#include + +namespace nes::app::mac +{ + /// File browser implementation using the POSIX directory API. + class file_browser_posix final : public file_browser + { + path_buffer<1024> path_; + DIR* it_{ nullptr }; + u32 it_pos_{ 0 }; + + public: + explicit file_browser_posix(); + ~file_browser_posix() override; + + auto get_path() const -> path_view override { return path_.get_components(); } + auto seek(u32) -> void override; + auto read_next(item* out_item) -> bool override; + auto navigate_up() -> status override; + auto navigate(std::string_view) -> status override; + auto load(std::string_view, span, u32* out_length) -> status override; + + private: + auto reopen_directory(std::string_view path) -> status; + }; +} // namespace nes::app::mac \ No newline at end of file -- cgit v1.3.1