Code: Select all
function MSused(dir)
local space = 0
--seed the 1st iteration with root of ms
dir = dir or "ms0:"
files = System.listDirectory(dir)
if files == nil then
-- NOT SURE IF THIS IS ACCURATE, BUT IT'S LESS ACCURATE WHEN LEFT OUT.
-- I'm assuming that folders take 16k of space (this makes no sense)
space = 16384
else
for index, file in files do
-- we convert the filesize to take account of the minimum 32k filesize
space = space + math.ceil(file.size/32768)*32768
if file.directory then space = space + MSused(dir .. "/" .. file.name) end
end
end
return space
end