Sirshark10

ListMod

Feb 13th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1.  
  2. local tArgs = { ... }
  3.  
  4. -- Get all the files in the directory
  5. local sDir = kernel.gwd()
  6. if tArgs[1] ~= nil then
  7. if kernel.gwd() ~= "/" then
  8. sDir = kernel.gwd().."/"..tArgs[1]
  9. else
  10. sDir = kernel.gwd()..tArgs[1]
  11. end
  12.  
  13. end
  14.  
  15. -- Sort into dirs/files, and calculate column count
  16. local tAll = fs.list( sDir )
  17. local tFiles = {}
  18. local tDirs = {}
  19.  
  20. for n, sItem in pairs( tAll ) do
  21. if string.sub( sItem, 1, 1 ) ~= "." then
  22. local sPath = fs.combine( sDir, sItem )
  23. if fs.isDir( sPath ) then
  24. table.insert( tDirs, sItem )
  25. else
  26. table.insert( tFiles, sItem )
  27. end
  28. end
  29. end
  30. table.sort( tDirs )
  31. table.sort( tFiles )
  32.  
  33. if term.isColour() then
  34. textutils.pagedTabulate( colors.green, tDirs, colors.white, tFiles )
  35. else
  36. textutils.pagedTabulate( tDirs, tFiles )
  37. end
Advertisement
Add Comment
Please, Sign In to add comment