From febe2b19a818aa8bf7e6534313281bf2ccd00ffe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20Ho=C5=A1ek?= Date: Sat, 27 Oct 2007 22:38:12 +0000 Subject: [PATCH] Fix for #245: OS X bundles can now be renamed. SVN-Revision: 5170 --- src/main.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 84160c7f0..2148861eb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,10 @@ #include #include +#ifdef MACOSX +# include +#endif + #include "gameconfig.hpp" #include "resources.hpp" #include "gettext.hpp" @@ -165,8 +169,18 @@ static void init_physfs(const char* argv0) #ifdef MACOSX // when started from Application file on Mac OS X... - dir = PHYSFS_getBaseDir(); - dir += "SuperTux.app/Contents/Resources/data"; + char path[PATH_MAX]; + CFBundleRef mainBundle = CFBundleGetMainBundle(); + assert(mainBundle != 0); + CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); + assert(mainBundleURL != 0); + CFStringRef pathStr = CFUrlCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle); + assert(pathStr != 0); + CFStringGetCString(pathStr, path, PATH_MAX, kCFStringEncodingUTF8); + CFRelease(mainBundleURL); + CFRelease(pathStr); + + dir = std::string(path) + "/Contents/Resources/data"; testfname = dir + "/credits.txt"; sourcedir = false; f = fopen(testfname.c_str(), "r"); -- 2.11.0