MACOSX: Pull a getResourceAppBundlePathMacOSX() wrapper from addSysArchivesToSearchSet()

This commit is contained in:
Donovan Watteau 2022-05-06 18:59:38 +02:00 committed by Thierry Crozat
parent 63e2c001bb
commit 5118c60874
3 changed files with 23 additions and 13 deletions

View file

@ -30,6 +30,7 @@
#include <Foundation/NSPathUtilities.h>
#include <AvailabilityMacros.h>
#include <CoreFoundation/CFString.h>
#include <CoreFoundation/CoreFoundation.h>
#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();
}