BananeMan

Untitled

Sep 3rd, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1.  
  2. local tArgs = { ... }
  3.  
  4. -- Get all the files in the directory
  5. local sDir = shell.dir()
  6. if tArgs[1] ~= nil then
  7. sDir = shell.resolve( tArgs[1] )
  8. end
  9.  
  10. -- Sort into dirs/files, and calculate column count
  11. local tAll = fs.list( sDir )
  12. local tFiles = {}
  13. local tDirs = {}
  14.  
  15. for n, sItem in pairs( tAll ) do
  16. if string.sub( sItem, 1, 1 ) ~= "." or "watcher.lua" 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. table.sort( tDirs )
  26. table.sort( tFiles )
  27.  
  28. if term.isColour() then
  29. textutils.pagedTabulate( colors.green, tDirs, colors.white, tFiles )
  30. else
  31. textutils.pagedTabulate( tDirs, tFiles )
  32. end
Add Comment
Please, Sign In to add comment