summaryrefslogtreecommitdiff
path: root/src/lua/include/file_iterator.hpp
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-05-02 17:02:58 +1000
committerailurux <ailuruxx@gmail.com>2024-05-02 17:02:58 +1000
commit4aed95a3cdf6eb39e158cb2333d09b354afe3614 (patch)
tree4d0ddf9e7bc3257b538a8557632d9f2ff115053c /src/lua/include/file_iterator.hpp
parent920345b940bb3993c389d9e9be1a75a8041d431d (diff)
downloadtangara-fw-4aed95a3cdf6eb39e158cb2333d09b354afe3614.tar.gz
WIP: Lua filesystem starting point
Diffstat (limited to 'src/lua/include/file_iterator.hpp')
-rw-r--r--src/lua/include/file_iterator.hpp42
1 files changed, 42 insertions, 0 deletions
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 <ailuruxx@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#pragma once
+
+#include <string>
+#include <optional>
+
+#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<FileEntry>&;
+ auto next() -> void;
+ auto prev() -> void;
+
+ private:
+ FF_DIR dir_;
+ std::string original_path_;
+
+ std::optional<FileEntry> current_;
+
+ auto iterate(bool reverse = false) -> bool;
+};
+
+} // namespace database \ No newline at end of file