-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree.lua
More file actions
32 lines (29 loc) · 808 Bytes
/
Copy pathtree.lua
File metadata and controls
32 lines (29 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local path = _G.argv[1]
if path == nil then path = "" end
path = fs.combine(hsh.getDir(),path)
local path2 = path
function traverseDirectory(path, indent)
local items = fs.list(path)
for _, item in ipairs(items) do
local itemPath = fs.combine(path, item)
if fs.isDir(itemPath) then
print(indent .. "|-- " .. item .. "/")
traverseDirectory(itemPath, indent .. " ")
else
print(indent .. "|-- " .. item)
end
end
end
function main()
if fs.exists(path) then
if fs.isDir(path) then
print(path .. "/")
traverseDirectory(path, "")
else
print("The provided path is not a directory.")
end
else
print("The provided path does not exist.")
end
end
main()