-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgreyhack_ChatGPT_ls_script
More file actions
34 lines (30 loc) · 914 Bytes
/
greyhack_ChatGPT_ls_script
File metadata and controls
34 lines (30 loc) · 914 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
33
34
// command: ls
if params.len > 2 then
print(command_info("ls_usage"))
else
computer = get_shell.host_computer
folderPath = current_path
if params.len == 2 then
folderPath = params[1]
end if
folder = computer.File(folderPath)
if folder == null then
print("ls: No such file or directory")
else
if not folder.has_permission("r") then
print("ls: permission denied")
else
subFiles = folder.get_folders + folder.get_files
output = ""
for subFile in subFiles
nameFile = subFile.name
size = subFile.size
if output.len > 0 then
output = output + "\n"
end if
output = output + nameFile + "\t" + size
end for
print(format_columns(output))
end if
end if
end if