From 4aed95a3cdf6eb39e158cb2333d09b354afe3614 Mon Sep 17 00:00:00 2001 From: ailurux Date: Thu, 2 May 2024 17:02:58 +1000 Subject: WIP: Lua filesystem starting point --- src/lua/include/file_iterator.hpp | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/lua/include/file_iterator.hpp (limited to 'src/lua/include/file_iterator.hpp') diff --git a/src/lua/include/file_iterator.hpp b/src/lua/include/file_iterator.hpp new file mode 100644 index 00000000..6fc58245 --- /dev/null +++ b/src/lua/include/file_iterator.hpp @@ -0,0 +1,42 @@ +/* + * Copyright 2023 ailurux + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include +#include + +#include "ff.h" + +namespace database { + +// Note for when reading FILINFO, that we are in LFN mode: +// http://elm-chan.org/fsw/ff/doc/sfileinfo.html +struct FileEntry { + bool isHidden; + bool isDirectory; + bool isTrack; + std::string filepath; +}; + +class FileIterator { + public: + FileIterator(std::string filepath); + + auto value() const -> const std::optional&; + auto next() -> void; + auto prev() -> void; + + private: + FF_DIR dir_; + std::string original_path_; + + std::optional current_; + + auto iterate(bool reverse = false) -> bool; +}; + +} // namespace database \ No newline at end of file -- cgit v1.2.3