Joachim de Groot avatar Joachim de Groot committed 6cdc58c

New possibility for a lib directory on OS X.

Comments (0)

Files changed (1)

 static void game_scores_save(game *g, GList *scores);
 static int game_score_compare(const void *scr_a, const void *scr_b);
-const char *default_lib_dir = "/usr/share/nlarn";
-const char *default_var_dir = "/var/games/nlarn";
+static const char *default_lib_dir = "/usr/share/nlarn";
+static const char *default_var_dir = "/var/games/nlarn";
 static const char *mesgfile = "nlarn.msg";
 static const char *helpfile = "nlarn.hlp";
 static const char *mazefile = "maze";
         char *cwd = g_get_current_dir();
         char *wdlibdir = g_build_path(G_DIR_SEPARATOR_S, cwd, "lib", NULL);
+#ifdef __APPLE__
+        char *rellibdir = g_build_path(G_DIR_SEPARATOR_S, nlarn->basedir,
+                                       "../Resources/NLarn", NULL);
         if (g_file_test(wdlibdir, G_FILE_TEST_IS_DIR))
             /* string has to be dup'd as it is feed in the end */
             nlarn->libdir = g_strdup((char *)default_lib_dir);
+#ifdef __APPLE__
+        else if (g_file_test(rellibdir, G_FILE_TEST_IS_DIR))
+        {
+            /* program seems to be installed relocateable */
+            nlarn->libdir = g_strdup(rellibdir);
+        }
             g_printerr("Could not find game library directory.\n\n"
                        "Paths I've tried:\n"
                        " * %s\n"
                        " * %s\n"
+#ifdef __APPLE__
+                       " * %s\n"
                        " * %s\n\n"
                        "Please reinstall the game.\n",
-                       nlarn->libdir, wdlibdir, default_lib_dir);
+                       nlarn->libdir, wdlibdir,
+#ifdef __APPLE__
+                       rellibdir,
+                       default_lib_dir);
+#ifdef __APPLE__
+            g_free(rellibdir);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.