PandaDoddo72Rus

Untitled

Jul 31st, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local fs = require("filesystem")
  2. local sh = require("shell")
  3. local serialization = require("serialization")
  4. local args= sh.parse(...)
  5. local uc = require("unicode")
  6.  
  7. function get(path)
  8.   local result = {}
  9.   for value in fs.list(path) do
  10.     if uc.sub(value,uc.len(value),uc.len(value)) ~= '/' then
  11.       result[#result+1] = value
  12.     else
  13.       result[path..value] = get(path..value)
  14.     end
  15.   end
  16.   return result
  17. end
  18.  
  19. local path = tostring(args[1])
  20.  
  21. local arr = get(path)
  22.  
  23. local size = 0
  24.  
  25. for val,val2 in pairs(arr) do
  26.   if type(val) == 'string' then
  27.     if uc.sub(val,uc.len(val),uc.len(val)) == '/' then
  28.       for value in fs.list(val) do
  29.         print(val..value)
  30.         size = size + fs.size(val..value)
  31.       end
  32.     else
  33.       size = size + fs.size(val..value)
  34.     end
  35.   elseif type(val) == 'number' then
  36.     size = size + fs.size(path..arr[val])
  37.   end
  38. end
  39.  
  40. print(size)
  41. print(serialization.serialize(get(tostring(args[1]))))
Add Comment
Please, Sign In to add comment