Gathering file names/ Directory Structure
Now that I've finally got music playing I'd like to set up the following:
The user can store their .ogg music files in 'mygame/music', where the .exe is in 'mygame'. I want to search that directory and gather all the titles of their tracks so I can load them in at runtime, and stream a random track at the start of a level.
Any suggestions as to how to go about doing this?
Also, somone mentioned that loading '/music/mytrack.ogg' in my program would cause problems if it was being run outside of DOS/ Windows, on account of the directory structure. What could I be doing instead to ensure compatability across all platforms?
Many thanks,
Dan
Assuming Windows, check out FindFirstFile on MSDN
hth
moe.ron
[edit]
Sorry, should have read the whole post better. Look into boost::filesystem for more info on cross-platform directory searching stuff.
Also using "/dir/subdir/file" should work just fine. Windows is the only system that doesn't use forward slashes I think, but they still work. I've never run into any issues with that. Maybe it would be better to use "./dir/subdir/file" for *NIX systems though so you start from the current working directory...Starting with the period would also be valid on Windows.
[Edited by - moeron on October 21, 2005 6:10:52 AM]
hth
moe.ron
[edit]
Sorry, should have read the whole post better. Look into boost::filesystem for more info on cross-platform directory searching stuff.
Also using "/dir/subdir/file" should work just fine. Windows is the only system that doesn't use forward slashes I think, but they still work. I've never run into any issues with that. Maybe it would be better to use "./dir/subdir/file" for *NIX systems though so you start from the current working directory...Starting with the period would also be valid on Windows.
[Edited by - moeron on October 21, 2005 6:10:52 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement