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

Author Topic: Relative path to MacOSX app bundle resource?  (Read 2855 times)

0 Members and 1 Guest are viewing this topic.

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Relative path to MacOSX app bundle resource?
« on: July 28, 2010, 06:24:30 pm »
Hello,

I'm working on a cross-platform app using SFML 1.6.  I'm currently using XCode 3.1.4 under MacOSX 10.5.8. I'd like to maintain a separate path for each platfrom to load its files from.  Mac seems to be the only one that uses relative path for its resources in an app bundle.  For now I've been using absolute paths to where my resources can be stored but that won't work in production code.

Here's how it's defined:
Code: [Select]

#ifndef __SYSTEM_SPECIFIC_H__
# define __SYSTEM_SPECIFIC_H__
# include <SFML/Config.hpp>
# ifdef SFML_SYSTEM_MACOS
# define RESOURCEPATH "../Resources/"
//# define RESOURCEPATH "/Users/samuraicrow/Documents/EventideCode/"
# else
#  ifdef SFML_SYSTEM_LINUX
#   define RESOURCEPATH "/usr/share/games/eventide/"
#  else
#   define RESOURCEPATH "Resources/"
#  endif
# endif
#endif

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Relative path to MacOSX app bundle resource?
« Reply #1 on: July 29, 2010, 01:30:38 am »
Mac isn't the single operating system that works with relative paths. Why don't you put the files inside the application directory (or a subdirectory)? It should be possible to use the same (relative) path for every platform.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Relative path to MacOSX app bundle resource?
« Reply #2 on: July 29, 2010, 10:58:17 am »
Quote from: "SamuraiCrow"
Code: [Select]
# define RESOURCEPATH "../Resources/"

Note that with SFML, the current working directory is always set to the Resources folder of the bundle application. Thus using [...]/Resources/../Resources points to... the Resources directory, as an empty string would.
Want to play movies in your SFML application? Check out sfeMovie!

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Relative path to MacOSX app bundle resource?
« Reply #3 on: July 29, 2010, 08:29:45 pm »
I found the problem.  I was still running an old version of SFML because I had dragged the frameworks to the wrong frameworks folder.