Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function merge(tbl1, tbl2)
- for i,v in ipairs(tbl2) do table.insert(tbl1, v) end
- return tbl1
- end
- function getFiles(root, recursive)
- local function helper(path)
- local retVal = {}
- local files = fs.list(path)
- for _,file in ipairs(files) do
- file = path.."/"..file
- local isDir = fs.isDir(file)
- if isDir and recursive then
- merge(retVal, helper(file))
- elseif not isDir then
- file = string.gsub(file,root.."/","")
- table.insert(retVal, file)
- end
- end
- return retVal
- end
- return helper(root)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement