From 4a14d162b12e843464f90f705c57dae8a5693964 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 30 May 2005 22:34:17 +0000 Subject: [PATCH] pick apart com_argv[0] to find basedir in Mac OSX when running from a .app package git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5362 d7cf8633-e32d-0410-b094-e92efae38249 --- fs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs.c b/fs.c index 6f7a4fc8..0b72b4d1 100644 --- a/fs.c +++ b/fs.c @@ -908,7 +908,15 @@ void FS_Init (void) #ifdef MACOSX // FIXME: is there a better way to find the directory outside the .app? if (strstr(com_argv[0], ".app/")) - strcpy(fs_basedir, "../../.."); + { + char *split; + char temp[4096]; + split = strstr(com_argv[0], ".app/"); + while (split > com_argv[0] && *split != '/') + split--; + strlcpy(fs_basedir, com_argv[0], sizeof(fs_basedir)); + fs_basedir[split - com_argv[0]] = 0; + } #endif PK3_OpenLibrary (); -- 2.39.2