diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-02-07 22:15:57 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-02-07 22:15:57 +0100 |
| commit | 0de4957a22dd408793d0526351bcb7d61786fe86 (patch) | |
| tree | 3160c72a45022b1e0b7e5ab928c690e85e20cded /app/sdl/impl/file-browser-posix.hh | |
| parent | a6bfb14562982c8c0139566e5a9b3051543791c4 (diff) | |
add sdl implementation
Diffstat (limited to 'app/sdl/impl/file-browser-posix.hh')
| -rw-r--r-- | app/sdl/impl/file-browser-posix.hh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/sdl/impl/file-browser-posix.hh b/app/sdl/impl/file-browser-posix.hh new file mode 100644 index 0000000..8d56575 --- /dev/null +++ b/app/sdl/impl/file-browser-posix.hh @@ -0,0 +1,30 @@ +#pragma once + +#include "nes/app/file-browser.hh" +#include "nes/common/containers/path-builder.hh" +#include <dirent.h> + +namespace nes::app::sdl +{ + /// 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(entry* out_entry) -> bool override; + auto navigate_up() -> status override; + auto navigate(string_view) -> status override; + auto load(string_view, span<u8>, u32* out_length) -> status override; + + private: + auto reopen_directory(string_view path) -> status; + }; +} // namespace nes::app::sdl |
