diff --git a/src/main/support_apple.mm b/src/main/support_apple.mm index f033131..604a998 100644 --- a/src/main/support_apple.mm +++ b/src/main/support_apple.mm @@ -1,5 +1,4 @@ #include "zelda_support.h" -#include #import #import #import @@ -19,35 +18,8 @@ namespace zelda64 { } std::filesystem::path get_bundle_directory() { - NSURL *bundleUrl = [[NSBundle mainBundle] bundleURL]; - - // The OS may relocate the app elsewhere for security reasons if, for example, - // it was downloaded and opened from the Downloads folder. In this case, we need - // to untranslocate the path to find out where the actual app bundle is. - if (void* securityHandle = dlopen("/System/Library/Frameworks/Security.framework/Security", RTLD_LAZY)) { - using IsTranslocatedURLFunc = Boolean (*)(CFURLRef path, bool* isTranslocated, - CFErrorRef* __nullable error); - using CreateOriginalPathForURLFunc = CFURLRef __nullable (*)(CFURLRef translocatedPath, - CFErrorRef* __nullable error); - - const auto IsTranslocatedURL = reinterpret_cast( - dlsym(securityHandle, "SecTranslocateIsTranslocatedURL")); - const auto CreateOriginalPathForURL = reinterpret_cast( - dlsym(securityHandle, "SecTranslocateCreateOriginalPathForURL")); - - bool translocated = false; - if (IsTranslocatedURL && CreateOriginalPathForURL && - IsTranslocatedURL((__bridge CFURLRef) bundleUrl, &translocated, nullptr) && translocated) { - CFURLRef untranslocated = CreateOriginalPathForURL((__bridge CFURLRef) bundleUrl, nullptr); - if (untranslocated) { - bundleUrl = (NSURL*) untranslocated; - } - } - - dlclose(securityHandle); - } - - return std::filesystem::path([bundleUrl fileSystemRepresentation]); + NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; + return std::filesystem::path([bundlePath UTF8String]); } }