diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index b23c190fdf4..0809ab0d686 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -43,8 +43,8 @@ #include "common/fs.h" #include "common/translation.h" -#include "ApplicationServices/ApplicationServices.h" // for LSOpenFSRef -#include "CoreFoundation/CoreFoundation.h" // for CF* stuff +#include // for LSOpenFSRef +#include // for CF* stuff // For querying number of MIDI devices #include @@ -132,17 +132,10 @@ void OSystem_MacOSX::addSysArchivesToSearchSet(Common::SearchSet &s, int priorit OSystem_POSIX::addSysArchivesToSearchSet(s, priority); // Get URL of the Resource directory of the .app bundle - CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); - if (fileUrl) { - // Try to convert the URL to an absolute path - UInt8 buf[MAXPATHLEN]; - if (CFURLGetFileSystemRepresentation(fileUrl, true, buf, sizeof(buf))) { - // Success: Add it to the search path - Common::String bundlePath((const char *)buf); - // Search with a depth of 2 so the shaders are found - s.add("__OSX_BUNDLE__", new Common::FSDirectory(bundlePath, 2), priority); - } - CFRelease(fileUrl); + Common::String bundlePath = getResourceAppBundlePathMacOSX(); + if (!bundlePath.empty()) { + // Success: search with a depth of 2 so the shaders are found + s.add("__OSX_BUNDLE__", new Common::FSDirectory(bundlePath, 2), priority); } } diff --git a/backends/platform/sdl/macosx/macosx_wrapper.h b/backends/platform/sdl/macosx/macosx_wrapper.h index 6e2f1ef4590..0af5ac09d9d 100644 --- a/backends/platform/sdl/macosx/macosx_wrapper.h +++ b/backends/platform/sdl/macosx/macosx_wrapper.h @@ -29,5 +29,6 @@ bool hasTextInClipboardMacOSX(); Common::U32String getTextFromClipboardMacOSX(); bool setTextInClipboardMacOSX(const Common::U32String &text); Common::String getDesktopPathMacOSX(); +Common::String getResourceAppBundlePathMacOSX(); #endif diff --git a/backends/platform/sdl/macosx/macosx_wrapper.mm b/backends/platform/sdl/macosx/macosx_wrapper.mm index f79c6c9909b..44ff0d317e6 100644 --- a/backends/platform/sdl/macosx/macosx_wrapper.mm +++ b/backends/platform/sdl/macosx/macosx_wrapper.mm @@ -30,6 +30,7 @@ #include #include #include +#include #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 #define NSPasteboardTypeString NSStringPboardType @@ -110,3 +111,18 @@ Common::String getDesktopPathMacOSX() { return Common::String(); return Common::String([path fileSystemRepresentation]); } + +Common::String getResourceAppBundlePathMacOSX() { + CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); + if (fileUrl) { + // Try to convert the URL to an absolute path + UInt8 buf[MAXPATHLEN]; + if (CFURLGetFileSystemRepresentation(fileUrl, true, buf, sizeof(buf))) { + CFRelease(fileUrl); + return Common::String((const char *)buf); + } + CFRelease(fileUrl); + } + + return Common::String(); +}