// flightgear
#include <GUI/MessageBox.hxx>
+#include <Main/options.hxx>
NSString* stdStringToCocoa(const std::string& s)
{
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
# include <Include/no_version.h>
#endif
-#ifdef __APPLE__
-# include <CoreFoundation/CoreFoundation.h>
-#endif
-
using std::string;
using std::sort;
using std::cout;
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
{