Advertisement
Mat484

dir

Dec 9th, 2020
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. local function loadApis()
  2. local apis = fs.list("/CC-DOS/apis/")
  3. for k,v in pairs(apis) do
  4. os.loadAPI("/CC-DOS/apis/"..v)
  5. end
  6. end
  7.  
  8. local args = {...}
  9. local cwd = sys.getcache("sys").current_path
  10. local drive = {}
  11. local drives = storage.getDrives()
  12.  
  13. if #args == 1 then
  14. cwd = args[1]
  15. end
  16.  
  17. for k,v in pairs(drives) do
  18. if v.NAME == sys.getcache("sys").current_drive then
  19. drive = v
  20. break
  21. end
  22. end
  23.  
  24. print(" Volume in drive "..sys.getcache("sys").current_drive.." is "..drive.LABEL)
  25. print(" Directory of "..sys.getcache("sys").current_drive..":\\"..cwd.."\n")
  26. local raw = fs.list(utils.dosPathToUnixPath(sys.getcache("sys").current_drive..":\\"..cwd))
  27. local contents = {}
  28. for k,v in pairs(raw) do
  29. if fs.isDir(v) then
  30. contents[#contents+1] = "<DIR> "..v
  31. end
  32. end
  33. for k,v in pairs(raw) do
  34. if not fs.isDir(v) then
  35. contents[#contents+1] = " "..fs.getSize(v).." "..v
  36. end
  37. end
  38. for k,v in pairs(contents) do
  39. print(v)
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement