]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: macosx re-add the else/if block for symlinked executable
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 9 Jan 2022 17:48:59 +0000 (09:48 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 9 Jan 2022 17:48:59 +0000 (09:48 -0800)
vm/os-macosx.mm

index bf41074ddb2f0bf4791be2551fd215c8751c17eb..bb008567226774aab4c6077e2945c45cde8a0876 100644 (file)
@@ -40,20 +40,25 @@ const char* default_image_path(void) {
 
   if ([path hasSuffix:@".app"] || [path hasSuffix:@".app/"]) {
     NSFileManager* mgr = [NSFileManager defaultManager];
+    NSString* root = [path stringByDeletingLastPathComponent];
+    NSString* resources = [path stringByAppendingPathComponent:@"Contents/Resources"];
 
     if (!isatty(fileno(stdin))) {
-        NSString* root = [path stringByDeletingLastPathComponent];
         [mgr changeCurrentDirectoryPath: root];
     }
 
-    NSString* imageInBundle =
-        [[path stringByAppendingPathComponent:@"Contents/Resources"]
-            stringByAppendingPathComponent:image];
-    NSString* imageAlongBundle = [[path stringByDeletingLastPathComponent]
-        stringByAppendingPathComponent:image];
+    NSString* imageInBundle = [resources stringByAppendingPathComponent:image];
+    NSString* imageAlongBundle = [root stringByAppendingPathComponent:image];
 
     returnVal = ([mgr fileExistsAtPath:imageInBundle] ? imageInBundle
                                                       : imageAlongBundle);
+  } else if ([executablePath hasSuffix:@".app/Contents/MacOS/factor"]) {
+    returnVal = executablePath;
+    returnVal = [returnVal stringByDeletingLastPathComponent];
+    returnVal = [returnVal stringByDeletingLastPathComponent];
+    returnVal = [returnVal stringByDeletingLastPathComponent];
+    returnVal = [returnVal stringByDeletingLastPathComponent];
+    returnVal = [returnVal stringByAppendingPathComponent:image];
 
   } else {
     returnVal = [path stringByAppendingPathComponent:image];