Archived

This topic is now archived and is closed to further replies.

Polling a Folder

This topic is 5150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, so my latest project is doing well. A little baseball game. I am using the great fmod for playing music, and at start up would like to get all the names of mp3 files in the "data/music" folder. These will differ as the idea is the user can put his own tunes in there, and they will get played. anyone know a quick way to get all the file names from a given folder?

Share this post


Link to post
Share on other sites
quote:
Original post by thec
Check the SDK for "FindFirstFile" and "FindNextFile". It''s what you''re looking for I think.

Albert


Isn''t there any other methods besides for use of these 2 functions together?

The reason I ask is.. because they require use of a wildcard for "searching" for certain files.. which means if you want to find ALL files, you use *. So, I would imagine that it has to do wild-card matching on each file.

Or does the function optimize when * is passed and ignore any matching in this case? I just want to know, because it seems like a needless slowdown for a simple task.

Share this post


Link to post
Share on other sites
I bet you waste more time creating the list of files than windows needs for finding the next matching file.
Using efficient algorithms the search for such matches happens in close-to-linear time. This is one of things I think even Microsoft does well.
Using naive algorithms and datastructures the creation of a variable length lists, takes forever. If anything goes wrong, I assume it''s on this end.

Share this post


Link to post
Share on other sites
Well of course it''s using wildcard, if you know what you were searching for, you would try to open it and see if your call causes an errror (fopen returns NULL for instance).

And as others said, it''s not a speed issue.

Albert

Share this post


Link to post
Share on other sites