From: havoc Date: Mon, 30 May 2005 22:34:17 +0000 (+0000) Subject: pick apart com_argv[0] to find basedir in Mac OSX when running from a .app package X-Git-Tag: xonotic-v0.1.0preview~4820 X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=4a14d162b12e843464f90f705c57dae8a5693964;p=xonotic%2Fdarkplaces.git 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 --- 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 ();