Sign in to follow this  
Guy Meh

Cross-platform way to get files and folders inside a given folder

Recommended Posts

I'm thinking I'd better implement saving into my game soon. In order to do that, I need to implement file dialogs. I need some cross-platform way (at least Mac and Windows) to find the files and folders inside a given start folder. My project is written in C++ and uses SDL, if that is any help.

Share this post


Link to post
Share on other sites
Quote:
Original post by Guy Meh
Anything that doesn't require Boost? :[


Java. Or you can do the same like the rest, and create your own file "dialogs".

Share this post


Link to post
Share on other sites
Quote:
Original post by Guy Meh
Anything that doesn't require Boost? :[
PhysFS. Might be a bit heavyweight for what you want, but it is a very decent system.
Quote:
Then again, I probably want to pick up Boost eventually...
QFT.
Quote:
Original post by Raghar
Java. Or you can do the same like the rest, and create your own file "dialogs".
Pretty sure he is in C++ here, and that this is about implementation, not GUI.

Share this post


Link to post
Share on other sites
You could also consider using a cross platform GUI toolkit like wxWidgets to handle things for you.

Share this post


Link to post
Share on other sites
Quote:
Original post by guvidu
I agree with SiCrane - WxWidget its what you need. Easy to use and very powerfull.
The OP asked for a way to iterate a directory - not render a GUI widget. wxWidgets is fine for an editor, but it is extremely hard to integrate in to a game.

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
PhysFS. Might be a bit heavyweight for what you want, but it is a very decent system.


I've read about PhysFS, since I was also thinking about using it to handle my save files. I've noticed though that it looks pretty low-level, where I'm pretty much working with raw bits. Is there any wrapper or something that makes it a bit higher-level, sort of like the iostream classes in C++?

Share this post


Link to post
Share on other sites
Quote:
Original post by Guy Meh
Is there any wrapper or something that makes it a bit higher-level, sort of like the iostream classes in C++?
There used to be a nice C++ wrapper as part of the ParaGUI distro, but I haven't touched that project in a couple of years, so whether or not it is still available and/or maintained is anyone's guess.

It shouldn't be much work to roll your own (naive) wrapper though, just a couple of classes and use stringstreams to format the output text. If you are using binary output instead, then the iostream interface is pretty lousy, and you wont loose anything by using PhysFS directly.

Share this post


Link to post
Share on other sites
Quote:
Original post by Guy Meh
Anything that doesn't require Boost? :[

Then again, I probably want to pick up Boost eventually...


Why don't you want to use boost? Ask yourself if you actually have a valid reason (your company doesn't allow 3rd party libs for instance).

Bottom line, if you're going to be using C++, do yourself a favour and get boost. Honestly, it takes about 30 mins to get up and running with it. Not only will you get the benefit of all the libs, but you will learn heaps about modern C++ idioms from it.

BTW I'd do away with file dialogs completely and just save your games in a set location. I really can't remember the last game I played where the game asked me where I want to save to.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this