Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sys = require("sys")
- local function walkdir(dir, ext, recurse)
- if type(dir) ~= "Directory" then
- dir = sys.Directory(dir)
- end
- if type(ext) == "string" then ext = {ext} end
- local entries = recurse or {}
- for entry in each(dir) do
- if type(entry) == "File" then
- if ext then
- for i = 1, #ext do
- if entry.filename:match(".%" .. ext[i] .. "$") then
- table.insert(entries, entry)
- entries[entry.fullpath] = entry
- end
- end
- else
- table.insert(entries, entry)
- entries[entry.fullpath] = entry
- end
- else
- entries = walkdir(entry, ext, entries)
- end
- end
- return entries
- end
- return walkdir
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement