diff --git a/worldeditadditions/init.lua b/worldeditadditions/init.lua index 834883c..fbc9a8c 100644 --- a/worldeditadditions/init.lua +++ b/worldeditadditions/init.lua @@ -18,6 +18,9 @@ wea.Queue = dofile(wea.modpath.."/utils/queue.lua") wea.LRU = dofile(wea.modpath.."/utils/lru.lua") wea.inspect = dofile(wea.modpath.."/utils/inspect.lua") +-- I/O compatibility layer +wea.io = dofile(wea.modpath.."/utils/io.lua") + wea.bit = dofile(wea.modpath.."/utils/bit.lua") diff --git a/worldeditadditions/utils/io.lua b/worldeditadditions/utils/io.lua new file mode 100644 index 0000000..4d83589 --- /dev/null +++ b/worldeditadditions/utils/io.lua @@ -0,0 +1,14 @@ +local io = { + -- Ref https://minetest.gitlab.io/minetest/minetest-namespace-reference/#utilities + scandir = function(dirpath) + return minetest.get_dir_list(dirpath, nil) + end, + scandir_files = function(dirpath) + return minetest.get_dir_list(dirpath, false) + end, + scandir_dirs = function(dirpath) + return minetest.get_dir_list(dirpath, true) + end, +} + +return io diff --git a/worldeditadditions/utils/strings/split.lua b/worldeditadditions/utils/strings/split.lua index 738b56f..541b86b 100644 --- a/worldeditadditions/utils/strings/split.lua +++ b/worldeditadditions/utils/strings/split.lua @@ -62,7 +62,7 @@ end -- @param plain boolean If true (or truthy), pattern is interpreted as a -- plain string, not a Lua pattern -- @returns table A sequence table containing the substrings -function worldeditadditions.split (str,dlm,plain) +function worldeditadditions.split(str,dlm,plain) local pos, ret = 0, {} local ins, i = str:find(dlm,pos,plain) -- "if plain" shaves off some time in the while statement