diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/qcommon/qcommon.h | 2 | ||||
-rw-r--r-- | src/sys/sys_main.c | 21 | ||||
-rw-r--r-- | src/sys/sys_osx.m | 17 |
3 files changed, 27 insertions, 13 deletions
diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index 495c9ca1..0e90963a 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -1072,6 +1072,8 @@ void Sys_ShowIP(void); FILE *Sys_FOpen( const char *ospath, const char *mode ); qboolean Sys_Mkdir( const char *path ); FILE *Sys_Mkfifo( const char *ospath ); +void Sys_SetBinaryPath(const char *path); +char *Sys_BinaryPath(void); void Sys_SetDefaultInstallPath(const char *path); char *Sys_DefaultInstallPath(void); diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c index c45b96c8..e5d93546 100644 --- a/src/sys/sys_main.c +++ b/src/sys/sys_main.c @@ -557,14 +557,6 @@ void Sys_ParseArgs( int argc, char **argv ) } } -#ifndef DEFAULT_BASEDIR -# ifdef MACOS_X -# define DEFAULT_BASEDIR Sys_StripAppBundle(Sys_BinaryPath()) -# else -# define DEFAULT_BASEDIR Sys_BinaryPath() -# endif -#endif - /* ================= Sys_SigHandler @@ -646,8 +638,19 @@ int main( int argc, char **argv ) #endif Sys_ParseArgs( argc, argv ); - Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); + if( strchr( argv[ 0 ], '/' ) +#ifdef _WIN32 + || strchr( argv[ 0 ], '\\' ) +#endif + ) + { + Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); + } +#if defined DEFAULT_BASEDIR Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); +#elif defined MACOS_X + Sys_SetDefaultInstallPath( Sys_StripAppBundle( Sys_BinaryPath() ) ); +#endif // Concatenate the command line for passing to Com_Init for( i = 1; i < argc; i++ ) diff --git a/src/sys/sys_osx.m b/src/sys/sys_osx.m index 5d567a7f..7e357ab2 100644 --- a/src/sys/sys_osx.m +++ b/src/sys/sys_osx.m @@ -98,7 +98,7 @@ Sys_StripAppBundle 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. +the result is returned. If not, an empty string is returned. ================= */ char *Sys_StripAppBundle( char *dir ) @@ -107,13 +107,22 @@ char *Sys_StripAppBundle( char *dir ) Q_strncpyz(cwd, dir, sizeof(cwd)); if(strcmp(Sys_Basename(cwd), "MacOS")) - return dir; + { + cwd[0] = '\0'; + return cwd; + } Q_strncpyz(cwd, Sys_Dirname(cwd), sizeof(cwd)); if(strcmp(Sys_Basename(cwd), "Contents")) - return dir; + { + cwd[0] = '\0'; + return cwd; + } Q_strncpyz(cwd, Sys_Dirname(cwd), sizeof(cwd)); if(!strstr(Sys_Basename(cwd), ".app")) - return dir; + { + cwd[0] = '\0'; + return cwd; + } Q_strncpyz(cwd, Sys_Dirname(cwd), sizeof(cwd)); return cwd; } |