aboutsummaryrefslogtreecommitdiffstats
path: root/code/unix/unix_main.c
diff options
context:
space:
mode:
authortjw <tjw@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-08-16 05:22:09 +0000
committertjw <tjw@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-08-16 05:22:09 +0000
commitbd8e88e4a00f4850cbdb495f441fa0aa4afe530d (patch)
treeb238ad45fa7ae07fda12eabfad90606bd642fd93 /code/unix/unix_main.c
parent51af4ceebe922d27ee3a93d2c763b5a3aedd5474 (diff)
downloadioquake3-aero-bd8e88e4a00f4850cbdb495f441fa0aa4afe530d.tar.gz
ioquake3-aero-bd8e88e4a00f4850cbdb495f441fa0aa4afe530d.zip
bug 2723
* replaced my cheap hack to search current working dir on OS X with a more complex hack that detects the .app bundle directory structure. This is so the game data dirs do not need to be inside of the .app bundle btw. git-svn-id: svn://svn.icculus.org/quake3/trunk@844 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/unix/unix_main.c')
-rw-r--r--code/unix/unix_main.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/code/unix/unix_main.c b/code/unix/unix_main.c
index 47746ab..c432026 100644
--- a/code/unix/unix_main.c
+++ b/code/unix/unix_main.c
@@ -1382,8 +1382,42 @@ void Sys_ParseArgs( int argc, char* argv[] ) {
}
}
+#ifdef MACOS_X
+/*
+=================
+Sys_EscapeAppBundle
+
+Discovers if passed dir is suffixed with the directory structure of a
+Mac OS X .app bundle. If it is, the .app directory structure is stripped off
+the end and the result is returned. If not, dir is returned untouched.
+
+=================
+*/
+char *Sys_StripAppBundle(char *dir)
+{
+ static char cwd[MAX_OSPATH];
+
+ Q_strncpyz(cwd, dir, sizeof(cwd));
+ if(strcmp(basename(cwd), "MacOS"))
+ return dir;
+ Q_strncpyz(cwd, dirname(cwd), sizeof(cwd));
+ if(strcmp(basename(cwd), "Contents"))
+ return dir;
+ Q_strncpyz(cwd, dirname(cwd), sizeof(cwd));
+ if(!strstr(basename(cwd), ".app"))
+ return dir;
+ Q_strncpyz(cwd, dirname(cwd), sizeof(cwd));
+ return cwd;
+}
+#endif /* MACOS_X */
+
#ifndef DEFAULT_BASEDIR
-# define DEFAULT_BASEDIR Sys_DefaultCDPath()
+ #ifdef MACOS_X
+ // if run from an .app bundle, we want to also search its containing dir
+ #define DEFAULT_BASEDIR Sys_StripAppBundle(Sys_DefaultCDPath())
+ #else
+ #define DEFAULT_BASEDIR Sys_DefaultCDPath()
+ #endif
#endif
#include "../client/client.h"