From 49e92c295ea8f2e2cd9b0b23c2ca1479e3f2db2a Mon Sep 17 00:00:00 2001 From: ailurux Date: Tue, 18 Feb 2025 10:39:16 +1100 Subject: [PATCH] Hotfix: Update filesystem iterator to work with changes to infinite list --- src/tangara/lua/lua_filesystem.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 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}};