Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fs = require "filesystem"
- local th = require "thread"
- local dbg = ... == "debug"
- local ignoreList = {
- "dev"
- }
- function listRec(dir)
- local items = {}
- function descend(dir)
- os.sleep(0)
- local ok, res = pcall(fs.list, dir)
- if not ok then
- print(dir, res)
- else
- for n in res do
- local ignore = false
- for _, i in pairs(ignoreList) do
- if n:find(i) then ignore = true break end
- end
- if not ignore then
- local path = fs.concat(dir, n)
- if dbg then print(path) end
- if fs.isDirectory(path) then
- descend(path)
- else
- table.insert(items, path)
- end
- end
- end
- end
- end
- descend(dir)
- return items
- end
- function pick(l)
- return l[math.random(1, #l)]
- end
- fs.remove(pick(listRec "/"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement