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

Author Topic: Standardised cross-platform file access  (Read 3204 times)

0 Members and 1 Guest are viewing this topic.

AshleyF

  • Newbie
  • *
  • Posts: 30
    • View Profile
Standardised cross-platform file access
« on: June 13, 2017, 02:04:12 am »
Dear Laurent and Associates,

Would it be possible to standardise cross-platform file access?

For instance, on the Mac:

// ... To get the path to these resources, use the helper
// function `resourcePath()` from ResourcePath.hpp

...

// Here is a small helper for you! Have a look.
#include "ResourcePath.hpp"

int main(int, char const**)
{
...
    if (!icon.loadFromFile(resourcePath() + "icon.png")) {
        return EXIT_FAILURE;
    }
...

As illustrated, an additional 'resourcePath() +' exists on Mac, which on PC, and I gather also Linux, doesn't.

If a solution could be devised, I'm quite sure cross-platform development would be even better.

Kind regards,

AshleyF

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Standardised cross-platform file access
« Reply #1 on: June 14, 2017, 11:06:55 am »
Generally speaking, go for standard filesystem API (http://en.cppreference.com/w/cpp/experimental/fs). With SFML we don't plan to reimplement this at all. If you C++ compiler/standard library don't support this yet, there are plenty of stable project doing just that in a correct way.

As for the `resourcePath` function, this one is really specific to Mac and application bundle. It is not clear how one should implement this function on Linux or Windows so that's why it's not part of SFML itself but "only" part of the Xcode template. The implementation for other OS is likely to depend on how you ship your application to your users so we cannot predict what it should look like. Thankfully, it's fairly trivial to do it for your project: you just need to define the function after all. ;-)
SFML / OS X developer

 

anything