]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/os-macosx.mm
audio.engine.test: cleanup using
[factor.git] / vm / os-macosx.mm
index bf41074ddb2f0bf4791be2551fd215c8751c17eb..71c70f7a489cf505f1a90c4e7c5a317c64a5e83e 100644 (file)
@@ -40,20 +40,21 @@ 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];