From a15293c86f7f11f1cd130cc92204bdea55f675aa Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 29 Apr 2011 10:55:57 +0200 Subject: [PATCH] untested changes so DP might work with this again. Who knows if they even compile. --- radiant/mainframe.cpp | 19 +++++++++++++++++-- tools/quake3/q3map2/path_init.c | 25 ++++++++++++++++++++----- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 31f4635c..4b580bc3 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -189,7 +189,22 @@ void VFS_Destroy() #endif void HomePaths_Realise() { -#if defined(POSIX) +#if defined(__APPLE__) + const char* prefix = g_pGameDescription->getKeyValue("prefix"); + if(!string_empty(prefix)) + { + StringOutputStream path(256); + path << DirectoryCleaned(g_get_home_dir()) << "Library/Application Support" << (prefix+1) << "/"; + if(!file_is_directory(path.c_str())) + { + path.clear(); + path << DirectoryCleaned(g_get_home_dir()) << prefix << "/"; + } + g_qeglobals.m_userEnginePath = path.c_str(); + Q_mkdir(g_qeglobals.m_userEnginePath.c_str()); + } + else +#elif defined(POSIX) const char* prefix = g_pGameDescription->getKeyValue("prefix"); if(!string_empty(prefix)) { @@ -207,7 +222,7 @@ void HomePaths_Realise() TCHAR mydocsdir[MAX_PATH + 1]; if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir)) { - path << DirectoryCleaned(mydocsdir) << "My Games/" << prefix << "/"; + path << DirectoryCleaned(mydocsdir) << "My Games/" << (prefix+1) << "/"; // win32: only add it if it already exists if(file_is_directory(path.c_str())) g_qeglobals.m_userEnginePath = path.c_str(); diff --git a/tools/quake3/q3map2/path_init.c b/tools/quake3/q3map2/path_init.c index 501317f6..224a518e 100644 --- a/tools/quake3/q3map2/path_init.c +++ b/tools/quake3/q3map2/path_init.c @@ -43,6 +43,7 @@ several games based on the Quake III Arena engine, in the form of "Q3Map2." #define MAX_GAME_PATHS 10 char *homePath; +qboolean homePathUsesDot; char installPath[ MAX_OS_PATH ]; int numBasePaths; @@ -65,8 +66,9 @@ gets the user's home dir (for ~/.q3a) #ifdef WIN32 #include #endif -char *LokiGetHomeDir( void ) +char *LokiGetHomeDir( qboolean *usedot ) { + *usedot = qtrue; #ifndef Q_UNIX #ifndef WIN32 return NULL; @@ -76,6 +78,7 @@ char *LokiGetHomeDir( void ) if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir)) { snprintf(buf, sizeof(buf), "%s/My Games", mydocsdir); + *usedot = qfalse; return buf; } return NULL; @@ -103,6 +106,18 @@ char *LokiGetHomeDir( void ) } endpwent(); } + + #ifdef __APPLE__ + { + static char foo[MAX_OSPATH]; + snprintf(foo, sizeof(foo), "%s/Library/Application Support", home); + if(access(foo, X_OK) == 0) + { + *usedot = qfalse; + home = foo; + } + } + #endif /* return it */ return home; @@ -125,10 +140,10 @@ void LokiInitPaths( char *argv0 ) strcpy( installPath, "../" ); /* get home dir */ - home = LokiGetHomeDir(); + home = LokiGetHomeDir(&homePathUsesDot); if( home == NULL ) home = "."; - + /* set home path */ homePath = home; #else @@ -141,7 +156,7 @@ void LokiInitPaths( char *argv0 ) /* get home dir */ - home = LokiGetHomeDir(); + home = LokiGetHomeDir(&homePathUsesDot); if( home == NULL ) home = "."; @@ -307,7 +322,7 @@ void AddHomeBasePath( char *path ) return; /* concatenate home dir and path */ - sprintf( temp, "%s/%s", homePath, path ); + sprintf( temp, "%s/%s", homePath, homePathUsesDot ? path : (path+1) ); #ifdef WIN32 { -- 2.39.2