matriculated
Joined: 04 Mar 2006 Posts: 31
|
Posted: Sat Mar 18, 2006 4:11 am Post subject: Calculating MS space used leads to errors |
|
|
So, I have this recursive function to find the memory stick space used which also takes into account cluster size but I'm always shy a few megs of space. Can anyone tell me why?
| Code: | 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
|
|
|