SFML community forums

General => Feature requests => Topic started by: Austin J on March 19, 2014, 01:59:01 am

Title: File/Directory Detection
Post by: Austin J on March 19, 2014, 01:59:01 am
  Forgive me if this has been requested before, but I couldn't find anything related to this so I'm going ahead making this request.

  I don't think SFML needs to handle much file I/O for you. It already loads major file formats like bitmaps and .png's, .wav etc... Other things are up to the user of SFML to do.

  One thing that I think would be really handy though...

  If you wanted to do something like go in a folder and detect what files are there (say the players different saves) you have to use OS specific code to do so. This adds some complexity to keeping your game cross platform.

  Personally just think it would be neat if SFML had a solution to detecting files and directories.
Title: Re: File/Directory Detection
Post by: Jesper Juhl on March 19, 2014, 02:05:48 am
  If you wanted to do something like go in a folder and detect what files are there (say the players different saves) you have to use OS specific code to do so. This adds some complexity to keeping your game cross platform.

Well, you don't actually have to use different code across platforms. The POSIX functions opendir/readdir/rewinddir/closedir work just fine on both Windows, OS X and Linux.

You could also consider using a library like PhysFS : https://icculus.org/physfs/

In any case; this is (IMHO) outside the scope of SFML.
Title: Re: File/Directory Detection
Post by: Nexus on March 19, 2014, 07:15:24 am
If you wanted to do something like go in a folder and detect what files are there (say the players different saves) you have to use OS specific code to do so.
No, there are several libraries that can do this. Boost.Filesystem is also a popular choice.
Title: Re: File/Directory Detection
Post by: Jesper Juhl on March 19, 2014, 07:20:51 am
Qt also provides cross-platform directory/file access and is fairly popular.