Advertisement
FFGFlash

api/path.lua

Sep 28th, 2021 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. local api = { LoadOrder = 100 }
  2. function api.Build()
  3.   local Path = {}
  4.   function Path.list(root, recursive)
  5.     local function helper(path)
  6.         local retVal = {}
  7.         local files = fs.list(path)
  8.         for _,file in ipairs(files) do
  9.           file = path.."/"..file
  10.           local isDir = fs.isDir(file)
  11.           if isDir and recursive then table.combine(retVal, helper(file))
  12.           elseif not isDir then
  13.             file = string.gsub(file,root.."/","")
  14.             table.insert(retVal, file)
  15.           end
  16.         end
  17.         return retVal
  18.     end
  19.     return helper(root)
  20.   end
  21.   return Path
  22. end
  23. return api
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement