]> git.mxchange.org Git - flightgear.git/commitdiff
One more Mac helper moved into CocoaHelpers.mm
authorJames Turner <zakalawe@mac.com>
Mon, 18 Nov 2013 15:52:30 +0000 (15:52 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 18 Nov 2013 15:52:30 +0000 (15:52 +0000)
src/GUI/CocoaHelpers.mm
src/Main/options.cxx

index 6ea15e2d5a52f58d97957aba1e2bfcb1f8cb74dc..8df796615f01739af8477d6d3977b1cf6547ba03 100644 (file)
@@ -32,6 +32,7 @@
 
 // flightgear
 #include <GUI/MessageBox.hxx>
+#include <Main/options.hxx>
 
 NSString* stdStringToCocoa(const std::string& s)
 {
@@ -122,3 +123,18 @@ SGPath platformDefaultDataPath()
     appData.append("FlightGear");
     return appData;
 }
+
+namespace flightgear
+{
+    
+std::string Options::platformDefaultRoot() const
+{
+    CocoaAutoreleasePool ap;
+    
+    NSURL* url = [[NSBundle mainBundle] resourceURL];
+    SGPath dataDir(URLToPath(url));
+    dataDir.append("data");
+    return dataDir.str();
+}
+    
+} // of namespace flightgear
index 06e57f36f35963d879ceae520903955346215f8e..691e7be2405623058820e71de5dd7e1209c3f3da 100644 (file)
 #  include <Include/no_version.h>
 #endif
 
-#ifdef __APPLE__
-#  include <CoreFoundation/CoreFoundation.h>
-#endif
-
 using std::string;
 using std::sort;
 using std::cout;
@@ -2356,30 +2352,7 @@ string Options::platformDefaultRoot() const
   return "..\\data";
 }
 #elif defined(__APPLE__)
-string Options::platformDefaultRoot() const
-{
-  /*
-   The following code looks for the base package inside the application 
-   bundle, in the standard Contents/Resources location. 
-   */
-  CFURLRef resourcesUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
-  
-  // look for a 'data' subdir
-  CFURLRef dataDir = CFURLCreateCopyAppendingPathComponent(NULL, resourcesUrl, CFSTR("data"), true);
-  
-  CFURLRef absoluteDataUrl = CFURLCopyAbsoluteURL(dataDir);
-  
-  // now convert down to a path, and the a c-string
-  CFStringRef path = CFURLCopyFileSystemPath(absoluteDataUrl, kCFURLPOSIXPathStyle);  
-  string root = CFStringGetCStringPtr(path, CFStringGetSystemEncoding());
-  
-  CFRelease(absoluteDataUrl);
-  CFRelease(resourcesUrl);
-  CFRelease(dataDir);
-  CFRelease(path);
-  
-  return root;
-}
+// platformDefaultRoot defined in CocoaHelpers.mm
 #else
 string Options::platformDefaultRoot() const
 {