So developers don’t have to think as much about platform differences…
Otherwise this function becomes really useless on OS X (and iOS) as I
have to create my own code for “those” platforms… (And I’m assuming
you means Contents/Resources
)…
(oops, yes, Contents/Resources, sorry.)
Just so I’m clear, you’re asking for a hint so you can do this…
// we put the data files somewhere else here, but only on Mac OS X!
#if defined(STEAM_BUILD) && defined(APPLE)
SDL_SetHint(SDL_HINT_FILESYSTEM_OSX_USE_RESOURCE_DIR, “1”);
#endif
std::string mypath = SDL_GetBaseDir();
…instead of this…
std::string mypath = SDL_GetBaseDir();
// we put the data files somewhere else, but only on Mac OS X!
#if defined(STEAM_BUILD) && defined(APPLE)
mypath += “Contents/Resources/”;
#endif
…or am I misunderstanding the problem?
Well… it would be more like this in the second case the way things currently are in your code
std::string mypath = SDL_GetBaseDir();
// we put the data files somewhere else, but only on Mac OS X!
#if defined(APPLE)
#if defined(STEAM_BUILD)
mypath += “…/”; // I don’t like appenting …'s I prefer realpaths!
#else
mypath += “Contents/Resources/”;
#endif
#endif
Now, one “nicety” of the way the SDL hint system works… Is I do not have to set my hints via the SDL_SetHint… I can set them via the env…
So I can add this to my Info.plist
LSEnvironment
SDL_FILESYSTEM_OSX_USE_RESOURCE_DIR
1
Now for we can detect whether the OS X app is packaged in a bundle or not and make the best guess as to the data dir (in bundle resource out of bundle exedir)… an alternative approach might be
char* SDL_GetDataDir(const char* existing_file);
and have it check platform specific known dirs and find the file that should be in the data dir. (it could be a relative dir/file e.g. audio/main.pak)
My main issue with this API is that it works cleanly on all platforms except OS X which makes it useless as I essentially have to resort to what I’m currently doing which is platform specific code to use binreloc on linux NSBundle resourcePath on Mac. And if users have to resort to that, there really isn’t much point to having the API in the first place. Being able to simply put a two liner of
std::string g_datapath, g_userpath;
g_datapath = SDL_GetDataDir();
g_userpath = SDL_GetUserDir();
is what people would expect. and would keep in line with the way the rest of SDL is written. (keep the #ifdefs away !!)
Edward Rudd
OutOfOrder.cc
Skype: outoforder_cc
317-674-3296On Aug 20, 2013, at 21:39 , Ryan C. Gordon wrote: