From 093702d7734ef394ccc0620310438701fec72577 Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 19 Oct 2003 19:15:41 +0000 Subject: [PATCH] James Turner: Here's a patch to locate the base package inside the application bundle on OS-X. The patch also disables the CPSForeground hack in boostrap.cxx, which is unnecessary if the we're running as a proper bundle rather than a Unix command line program. Both of these changes are only compiled if OSX_BUNDLE is defined (I'm doing this via a setting in ProjectBuilder), so if you're building on OS-X using configure + make, you shouldn't see any chance. --- src/Main/bootstrap.cxx | 2 +- src/Main/fg_init.cxx | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Main/bootstrap.cxx b/src/Main/bootstrap.cxx index 588f1ab07..6d711801b 100644 --- a/src/Main/bootstrap.cxx +++ b/src/Main/bootstrap.cxx @@ -120,7 +120,7 @@ int main ( int argc, char **argv ) { #endif // Keyboard focus hack -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(OSX_BUNDLE) { PSN psn; diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index f308de7e8..c3662cfc9 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -268,8 +268,27 @@ bool fgInitFGRoot ( int argc, char **argv ) { root = "/FlightGear"; #elif defined( WIN32 ) root = "\\FlightGear"; -#elif defined( macintosh ) - root = ""; +#elif defined(OSX_BUNDLE) + /* the following code looks for the base package directly inside + the application bundle. This can be changed fairly easily by + fiddling with the code below. And yes, I know it's ugly and verbose. + */ + CFBundleRef appBundle = CFBundleGetMainBundle(); + CFURLRef appUrl = CFBundleCopyBundleURL(appBundle); + CFRelease(appBundle); + + // look for a 'data' subdir directly inside the bundle : is there + // a better place? maybe in Resources? I don't know ... + CFURLRef dataDir = CFURLCreateCopyAppendingPathComponent(NULL, appUrl, CFSTR("data"), true); + + // now convert down to a path, and the a c-string + CFStringRef path = CFURLCopyFileSystemPath(dataDir, kCFURLPOSIXPathStyle); + root = CFStringGetCStringPtr(path, CFStringGetSystemEncoding()); + + // tidy up. + CFRelease(appBundle); + CFRelease(dataDir); + CFRelease(path); #else root = PKGLIBDIR; #endif -- 2.39.5