summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tangara/lua/lua_filesystem.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/tangara/lua/lua_filesystem.cpp b/src/tangara/lua/lua_filesystem.cpp
index 9c2ea880..b7d446f3 100644
--- a/src/tangara/lua/lua_filesystem.cpp
+++ b/src/tangara/lua/lua_filesystem.cpp
@@ -86,6 +86,19 @@ static auto fs_iterator_clone(lua_State* state) -> int {
return 1;
}
+static auto fs_iterator_value(lua_State* state) -> int {
+ lua::FileIterator* it = check_file_iterator(state, 1);
+ std::optional<lua::FileEntry> res = it->value();
+
+ if (res) {
+ push_lua_file_entry(state, *res);
+ } else {
+ lua_pushnil(state);
+ }
+
+ return 1;
+}
+
static auto fs_iterator_gc(lua_State* state) -> int {
lua::FileIterator* it = check_file_iterator(state, 1);
delete it;
@@ -95,6 +108,7 @@ static auto fs_iterator_gc(lua_State* state) -> int {
static const struct luaL_Reg kFileIteratorFuncs[] = {{"next", fs_iterate},
{"prev", fs_iterate_prev},
{"clone", fs_iterator_clone},
+ {"value", fs_iterator_value},
{"__call", fs_iterate},
{"__gc", fs_iterator_gc},
{NULL, NULL}};