mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2026-05-08 01:51:37 +00:00
Remove translocated bundle handling.
Only really useful for portable mode with a downloaded bundle in the Downloads folder.
This commit is contained in:
parent
0aff04ba4b
commit
eead6db017
1 changed files with 2 additions and 30 deletions
|
|
@ -1,5 +1,4 @@
|
|||
#include "zelda_support.h"
|
||||
#include <dlfcn.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <objc/runtime.h>
|
||||
#import <objc/message.h>
|
||||
|
|
@ -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<IsTranslocatedURLFunc>(
|
||||
dlsym(securityHandle, "SecTranslocateIsTranslocatedURL"));
|
||||
const auto CreateOriginalPathForURL = reinterpret_cast<CreateOriginalPathForURLFunc>(
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue