]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/os-macosx.mm
webapps.wiki: adding search bar
[factor.git] / vm / os-macosx.mm
index 4f1944a90c9f0dbae89482fcdff122bac931e854..71c70f7a489cf505f1a90c4e7c5a317c64a5e83e 100644 (file)
@@ -2,6 +2,8 @@
 
 #include <mach/mach_time.h>
 #include <sys/utsname.h>
+#include <unistd.h>
+#include <stdio.h>
 
 #include "master.hpp"
 
@@ -38,15 +40,11 @@ const char* default_image_path(void) {
 
   if ([path hasSuffix:@".app"] || [path hasSuffix:@".app/"]) {
     NSFileManager* mgr = [NSFileManager defaultManager];
-
     NSString* root = [path stringByDeletingLastPathComponent];
-    [mgr changeCurrentDirectoryPath: root];
+    NSString* resources = [path stringByAppendingPathComponent:@"Contents/Resources"];
 
-    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);
@@ -57,6 +55,7 @@ const char* default_image_path(void) {
     returnVal = [returnVal stringByDeletingLastPathComponent];
     returnVal = [returnVal stringByDeletingLastPathComponent];
     returnVal = [returnVal stringByAppendingPathComponent:image];
+
   } else {
     returnVal = [path stringByAppendingPathComponent:image];
   }