Advertisement
Kodos

size.lua

Dec 8th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  1. local shell = require("shell")
  2. local fs = require("filesystem")
  3.  
  4. local args, options = shell.parse(...)
  5.  
  6. local file = args[1]
  7.  
  8. size = fs.size(file)
  9.  
  10. function round(num, idp)
  11. local mult = 10^(idp or 0)
  12. return math.floor(num * mult + 0.5) / mult
  13. end
  14.  
  15. if not options.a and size >= 1024 then
  16. size = size / 1024
  17. size = round(size, 2)
  18. print("File size of " .. file .. " is " .. size .. " kilobytes.")
  19. elseif options.a == true or size <= 1024 then  print("File size of " .. file .. " is " .. size .. " bytes.")
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement