Advertisement
fishermedders

FishOS /bin/List

Nov 6th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 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. local fFiles = {}
  15.  
  16. for n, sItem in pairs( tAll ) do
  17. if string.sub( sItem, 1, 1 ) ~= "." then
  18. local sPath = fs.combine( sDir, sItem )
  19. if fs.isDir( sPath ) then
  20. if sPath ~= "rom" then
  21. table.insert( tDirs, sItem )
  22. end
  23. else
  24. local ffile = false
  25. if #sItem >= 3 then
  26. if sItem:sub(#sItem-2,#sItem) == ".ff" then
  27. table.insert( fFiles, sItem )
  28. ffile = true
  29. end
  30. end
  31. if not ffile then
  32. table.insert( tFiles, sItem )
  33. end
  34. end
  35. end
  36. end
  37. table.sort( tDirs )
  38. table.sort( tFiles )
  39.  
  40. if term.isColour() then
  41. textutils.pagedTabulate( colors.blue, tDirs, colors.white, tFiles, colors.red, fFiles )
  42. else
  43. textutils.pagedTabulate( tDirs, tFiles )
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement