BananeMan

Untitled

Sep 3rd, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. local tArgs = { ... }
  2.  
  3. -- Get all the files in the directory
  4. local sDir = shell.dir()
  5. if tArgs[1] ~= nil then
  6. sDir = shell.resolve( tArgs[1] )
  7. end
  8.  
  9. -- Sort into dirs/files, and calculate column count
  10. local tAll = fs.list( sDir )
  11. local tFiles = {}
  12. local tDirs = {}
  13.  
  14. for n, sItem in pairs( tAll ) do
  15. if sItem ~= "watcher.lua" then
  16. if string.sub( sItem, 1, 1 ) ~= "." then
  17. local sPath = fs.combine( sDir, sItem )
  18. if fs.isDir( sPath ) then
  19. table.insert( tDirs, sItem )
  20. else
  21. table.insert( tFiles, sItem )
  22. end
  23. end
  24. end
  25. end
  26. table.sort( tDirs )
  27. table.sort( tFiles )
  28.  
  29. if term.isColour() then
  30. textutils.pagedTabulate( colors.green, tDirs, colors.white, tFiles )
  31. else
  32. textutils.pagedTabulate( tDirs, tFiles )
  33. end
  34.  
  35. function shell()
  36. if fs.exist("/.etat") then
  37. shell.run("shell")
  38. else
  39. fs.copy("/list", "/.etat")
  40. shell.run("shell")
  41. end
  42. end
  43.  
  44. function mai()
  45. while true do
  46. print("ok")
  47. sleep(10)
  48. end
  49. end
  50. shell()
Add Comment
Please, Sign In to add comment