]> git.mxchange.org Git - flightgear.git/commitdiff
James Turner:
authorehofman <ehofman>
Sun, 19 Oct 2003 19:15:41 +0000 (19:15 +0000)
committerehofman <ehofman>
Sun, 19 Oct 2003 19:15:41 +0000 (19:15 +0000)
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
src/Main/fg_init.cxx

index 588f1ab077f29f62019e9f59d160ebf253d02f40..6d711801b9fc31fcdb677bc5d5495ddf02ac38d9 100644 (file)
@@ -120,7 +120,7 @@ int main ( int argc, char **argv ) {
 #endif
 
     // Keyboard focus hack
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(OSX_BUNDLE)
     {
       PSN psn;
 
index f308de7e869cf1d11eebae9f5be4db7b213d7b58..c3662cfc93fe7fd3edc72608a926af90ac03b635 100644 (file)
@@ -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