]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/path_init.c
q3map2: use ~/Library/Application Support on Mac
[xonotic/netradiant.git] / tools / quake3 / q3map2 / path_init.c
index 725f2bbf81b9a75713eeb71012792430409448b5..96b33fcbae6d39cfd9decb777018d76d94f5845a 100644 (file)
 
 qboolean                               customHomePath = qfalse;
 char                    *homePath;
+
+#if GDEF_OS_MACOS
+char                                   *macLibraryApplicationSupportPath;
+#endif
+
 #if (GDEF_OS_POSIX && !GDEF_OS_MACOS)
 char                    *xdgDataHomePath;
 #endif // (GDEF_OS_POSIX && !GDEF_OS_MACOS)
+
 char installPath[ MAX_OS_PATH ];
 
 int numBasePaths;
@@ -117,6 +123,12 @@ void LokiInitPaths( char *argv0 ){
                home = homePath;
        }
 
+       #if GDEF_OS_MACOS
+               char *subPath = "/Library/Application Support";
+               macLibraryApplicationSupportPath = safe_malloc( sizeof( char ) * ( strlen( home ) + strlen( subPath ) ) );
+               sprintf( macLibraryApplicationSupportPath, "%s%s", home, subPath );
+       #endif // GDEF_OS_MACOS
+
        #if (GDEF_OS_POSIX && !GDEF_OS_MACOS)
        xdgDataHomePath = getenv( "XDG_DATA_HOME" );
 
@@ -324,6 +336,22 @@ void AddHomeBasePath( char *path ){
                char *tempHomePath;
                tempHomePath = homePath;
 
+               /* homePath is . on Windows if not user supplied */
+
+               #if GDEF_OS_MACOS
+               /*
+                  use ${HOME}/Library/Application as ${HOME}
+                  if home path is not user supplied
+                  and strip the leading dot from prefix in any case
+                 
+                  basically it produces
+                  ${HOME}/Library/Application/unvanquished
+                  /user/supplied/home/path/unvanquished
+               */
+               tempHomePath = macLibraryApplicationSupportPath;
+               path = path + 1;
+               #endif // GDEF_OS_MACOS
+
                #if (GDEF_OS_POSIX && !GDEF_OS_MACOS)
                /*
                   on Linux, check if game uses ${XDG_DATA_HOME}/prefix instead of ${HOME}/.prefix