]> git.tdb.fi Git - libs/core.git/commitdiff
OS X tweaks
authorMikko Rasa <tdb@tdb.fi>
Fri, 4 Oct 2013 21:44:41 +0000 (00:44 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 4 Oct 2013 21:46:51 +0000 (00:46 +0300)
source/core/unix/main.cpp
source/fs/dir.cpp

index 601ddb6f998ee0ac188f0113e5687e78a56fc018..698ec69ad514ee4d62d20b14ed9a9ec31ae6ff53 100644 (file)
@@ -2,5 +2,23 @@
 
 int main(int argc, char **argv)
 {
-       return Msp::Application::run(argc, argv);
+       void *data = 0;
+
+#ifdef __APPLE__
+       /* Applications launched from Finder get a special argument, which would
+       interfere with GetOpt.  Remove it from argv but pass it as data so it can
+       be used to determine how the application was launhed. */
+       int j = 0;
+       for(int i=0; i<argc; ++i)
+       {
+               if(!strncmp(argv[i], "-psn_", 5))
+                       data = argv[i];
+               else
+                       argv[j++] = argv[i];
+       }
+       argc = j;
+       argv[j] = 0;
+#endif
+
+       return Msp::Application::run(argc, argv, data);
 }
index 57fd9368f2b311da99ea1cb3a2fc1ccdaf286510..f77584708bb20a94d01496da33465dd0ffec40c7 100644 (file)
@@ -146,6 +146,8 @@ Path get_sys_data_dir(const string &argv0, const string &appname)
 
        if(dir[-1]=="bin" || dir[-1]=="sbin")
                return dir/".."/"share"/appname;
+       else if(dir[-1]=="MacOS")
+               return dir/".."/"Resources";
        else
                return dir;
 }