BananeMan

Untitled

Sep 3rd, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 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. if sItem ~= "list" then
  26. if string.sub( sItem, 1, 1 ) ~= "." then
  27. local sPath = fs.combine( sDir, sItem )
  28. if fs.isDir( sPath ) then
  29. table.insert( tDirs, sItem )
  30. else
  31. table.insert( tFiles, sItem )
  32. end
  33. end
  34. end
  35. end
  36. table.sort( tDirs )
  37. table.sort( tFiles )
  38.  
  39. if term.isColour() then
  40. textutils.pagedTabulate( colors.green, tDirs, colors.white, tFiles )
  41. else
  42. textutils.pagedTabulate( tDirs, tFiles )
  43. end
Add Comment
Please, Sign In to add comment