From eead6db01783f5f315de8d8d97bcc68df16e5fcf Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sun, 23 Mar 2025 11:37:18 -0700 Subject: [PATCH] Remove translocated bundle handling. Only really useful for portable mode with a downloaded bundle in the Downloads folder. --- src/main/support_apple.mm | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) 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]); } }