Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: File/Directory Detection  (Read 3159 times)

0 Members and 1 Guest are viewing this topic.

Austin J

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
File/Directory Detection
« 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.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: File/Directory Detection
« Reply #1 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.
« Last Edit: March 19, 2014, 02:10:51 am by Jesper Juhl »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: File/Directory Detection
« Reply #2 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: File/Directory Detection
« Reply #3 on: March 19, 2014, 07:20:51 am »
Qt also provides cross-platform directory/file access and is fairly popular.

 

anything