/** * @brief Gets Naev's cache path (for cached data such as generated textures) * * @return The xdg cache path. */ const char* nfile_cachePath (void) { char *path; if (naev_cachePath[0] == '\0') { #if HAS_UNIX path = xdgGetRelativeHome( "XDG_CACHE_HOME", "/.cache" ); if (path == NULL) { WARN("$XDG_CACHE_HOME isn't set, using current directory."); path = strdup("."); } nsnprintf( naev_cachePath, PATH_MAX, "%s/naev/", path ); if (path != NULL) { free (path); } #elif HAS_WIN32 path = SDL_getenv("APPDATA"); if (path == NULL) { WARN("%%APPDATA%% isn't set, using current directory."); path = "."; } nsnprintf( naev_cachePath, PATH_MAX, "%s/naev/", path ); #else #error "Feature needs implementation on this Operating System for Naev to work." #endif } return naev_cachePath; }
const char * xdgConfigHome(xdgHandle *handle) { if (handle) return xdgGetCache(handle)->configHome; else return xdgGetRelativeHome("XDG_CONFIG_HOME", DefaultRelativeConfigHome, sizeof(DefaultRelativeConfigHome)-1); }
const char * xdgCacheHome(xdgHandle *handle) { if (handle) return xdgGetCache(handle)->cacheHome; else return xdgGetRelativeHome("XDG_CACHE_HOME", DefaultRelativeCacheHome, sizeof(DefaultRelativeCacheHome)-1); }
const char * xdgDataHome(xdgHandle *handle) { if (handle) return xdgGetCache(handle)->dataHome; else return xdgGetRelativeHome("XDG_DATA_HOME", DefaultRelativeDataHome, sizeof(DefaultRelativeDataHome)-1); }
/** * @brief Gets Naev's data path (for user data such as saves and screenshots) * * @return The xdg data path. */ const char* nfile_dataPath (void) { char *path; if (naev_dataPath[0] == '\0') { /* Global override is set. */ if (conf.datapath) { nsnprintf( naev_dataPath, PATH_MAX, "%s/", conf.datapath ); return naev_dataPath; } #if HAS_UNIX path = xdgGetRelativeHome( "XDG_DATA_HOME", "/.local/share" ); if (path == NULL) { WARN("$XDG_DATA_HOME isn't set, using current directory."); path = strdup("."); } nsnprintf( naev_dataPath, PATH_MAX, "%s/naev/", path ); if (path != NULL) { free (path); } #elif HAS_WIN32 path = SDL_getenv("APPDATA"); if (path == NULL) { WARN("%%APPDATA%% isn't set, using current directory."); path = "."; } nsnprintf( naev_dataPath, PATH_MAX, "%s/naev/", path ); #else #error "Feature needs implementation on this Operating System for Naev to work." #endif } return naev_dataPath; }