forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calculating MS space used leads to errors

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
matriculated



Joined: 04 Mar 2006
Posts: 31

PostPosted: Sat Mar 18, 2006 4:11 am    Post subject: Calculating MS space used leads to errors Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group