summaryrefslogtreecommitdiff
path: root/test/demo.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-07-23 09:23:06 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-07-23 09:24:29 +0200
commite2d3b038996a0b9520565665481f652a1b6b45bc (patch)
tree3b3a719c8cf4076a569839a9a7072fc7a8cc2835 /test/demo.cxx
parent5fa367c2cf5c83ed4beee05dd4ce54489a487ab7 (diff)
Simpler macOS-specific code.
Diffstat (limited to 'test/demo.cxx')
-rw-r--r--test/demo.cxx16
1 files changed, 5 insertions, 11 deletions
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]);