r844 - in trunk/code: qcommon unix
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Wed Aug 16 01:22:10 EDT 2006
Author: tjw
Date: 2006-08-16 01:22:09 -0400 (Wed, 16 Aug 2006)
New Revision: 844
Modified:
trunk/code/qcommon/files.c
trunk/code/unix/unix_main.c
Log:
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.
Modified: trunk/code/qcommon/files.c
===================================================================
--- trunk/code/qcommon/files.c 2006-08-15 19:39:05 UTC (rev 843)
+++ trunk/code/qcommon/files.c 2006-08-16 05:22:09 UTC (rev 844)
@@ -2829,10 +2829,6 @@
if (fs_basepath->string[0]) {
FS_AddGameDirectory( fs_basepath->string, gameName );
}
-#ifdef MACOS_X
- // allow .app bundles to be placed along side base dir
- FS_AddGameDirectory( ".", gameName );
-#endif
// fs_homepath is somewhat particular to *nix systems, only add if relevant
// NOTE: same filtering below for mods and basegame
if (fs_basepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) {
Modified: trunk/code/unix/unix_main.c
===================================================================
--- trunk/code/unix/unix_main.c 2006-08-15 19:39:05 UTC (rev 843)
+++ trunk/code/unix/unix_main.c 2006-08-16 05:22:09 UTC (rev 844)
@@ -1382,8 +1382,42 @@
}
}
+#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"
More information about the quake3-commits
mailing list