From e2d3b038996a0b9520565665481f652a1b6b45bc Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 23 Jul 2020 09:23:06 +0200 Subject: Simpler macOS-specific code. --- test/demo.cxx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/demo.cxx b/test/demo.cxx index fa2b04bf4..d7a6bbc51 100644 --- a/test/demo.cxx +++ b/test/demo.cxx @@ -510,17 +510,11 @@ int main(int argc, char **argv) { #ifdef __APPLE__ { - // Starting with macOS 10.12, the actual location of the app has a - // randomized path to fix a vulnerability. - // We need some "Apple magic" ;-) to find the actual app_path. - - app_path[0] = 0; - CFBundleRef app = CFBundleGetMainBundle(); - CFURLRef url = CFBundleCopyBundleURL(app); - CFStringRef cc_app_path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); - CFRelease(url); - CFStringGetCString(cc_app_path, app_path, 2048, kCFStringEncodingUTF8); - CFRelease(cc_app_path); + char *p = strdup(argv[0]); + char *q = strstr(p, "/Contents/MacOS/"); + if (q) *q = 0; + fl_filename_absolute(app_path, sizeof(app_path), p); + free(p); } #else fl_filename_absolute(app_path, sizeof(app_path), argv[0]); -- cgit v1.2.3