Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fs = require("filesystem")
- local sh = require("shell")
- local serialization = require("serialization")
- local args= sh.parse(...)
- local uc = require("unicode")
- function get(path)
- local result = {}
- for value in fs.list(path) do
- if uc.sub(value,uc.len(value),uc.len(value)) ~= '/' then
- result[#result+1] = value
- else
- result[path..value] = get(path..value)
- end
- end
- return result
- end
- local path = tostring(args[1])
- local arr = get(path)
- local size = 0
- for val,val2 in pairs(arr) do
- if type(val) == 'string' then
- if uc.sub(val,uc.len(val),uc.len(val)) == '/' then
- for value in fs.list(val) do
- print(val..value)
- size = size + fs.size(val..value)
- end
- else
- size = size + fs.size(val..value)
- end
- elseif type(val) == 'number' then
- size = size + fs.size(path..arr[val])
- end
- end
- print(size)
- print(serialization.serialize(get(tostring(args[1]))))
Add Comment
Please, Sign In to add comment