Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- (C) PROMETHEUS TECHNLOGIES 2022
- tree.lua v1.0
- Lua recursive directory printer
- ]]
- local dir
- if #arg==0 then
- dir = shell.dir()
- else
- dir = arg[1]
- end
- if not fs.isDir(dir) then
- printError("Not a directory")
- end
- function recursiveList(d,i)
- i = i or 0
- for _,n in pairs(fs.list(d)) do
- local sd = d..'/'..n
- if fs.isDir(sd) then
- print(string.rep(" ",i)..n..'/')
- recursiveList(sd,i+1)
- else
- print(string.rep(" ",i)..n)
- end
- end
- end
- recursiveList(dir,0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement