From: James Turner Date: Mon, 18 Nov 2013 15:52:30 +0000 (+0000) Subject: One more Mac helper moved into CocoaHelpers.mm X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=23319565396cb2c87a28d74afe3e47e47fb1d435;p=flightgear.git One more Mac helper moved into CocoaHelpers.mm --- diff --git a/src/GUI/CocoaHelpers.mm b/src/GUI/CocoaHelpers.mm index 6ea15e2d5..8df796615 100644 --- a/src/GUI/CocoaHelpers.mm +++ b/src/GUI/CocoaHelpers.mm @@ -32,6 +32,7 @@ // flightgear #include +#include
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 diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 06e57f36f..691e7be24 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -76,10 +76,6 @@ # include #endif -#ifdef __APPLE__ -# include -#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 {