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 

Detect files?

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



Joined: 22 Aug 2005
Posts: 35

PostPosted: Thu Nov 10, 2005 9:19 am    Post subject: Detect files? Reply with quote

Is there a way to find out how many files are in a folder and save it to a variable?
Back to top
View user's profile Send private message
Durante



Joined: 02 Oct 2005
Posts: 65
Location: Austria

PostPosted: Thu Nov 10, 2005 9:49 am    Post subject: Reply with quote

Not very clean or efficient, but short:
Code:

function System.numFiles(dir)
  -- - 2 to not count . and .. (remove if you want to count them)
  return table.getn(System.listDirectory(dir)) - 2
end


If you don't want to count subfolders as files you'll have to do a bit more work ;)
Back to top
View user's profile Send private message
soulphalanx



Joined: 22 Aug 2005
Posts: 35

PostPosted: Thu Nov 10, 2005 10:21 am    Post subject: Reply with quote

files = System.numFiles("/dir/dir/") , where "dir" is a directory, isnt working

Last edited by soulphalanx on Fri Nov 11, 2005 10:28 am; edited 1 time in total
Back to top
View user's profile Send private message
soulphalanx



Joined: 22 Aug 2005
Posts: 35

PostPosted: Fri Nov 11, 2005 10:27 am    Post subject: Reply with quote

is there a more efficient method?
Back to top
View user's profile Send private message
MagicianFB



Joined: 10 Oct 2005
Posts: 11

PostPosted: Sat Nov 12, 2005 2:30 am    Post subject: Reply with quote

table.getn(System.listDirectory())

If you're not in the root directory you'll get to extra files.
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