Description: Write temporary data to $XDG_CACHE_HOME From: Sébastien Noel Forwarded: https://github.com/DescentDevelopers/Descent3/pull/625 --- a/Descent3/init.cpp +++ b/Descent3/init.cpp @@ -2002,14 +2002,24 @@ void SetupTempDirectory(void) { if (t_arg) { strcpy(Descent3_temp_directory, GameArgs[t_arg + 1]); } else { - std::error_code ec; - std::filesystem::path tempPath = std::filesystem::temp_directory_path(ec); - if (ec) { - Error("Could not find temporary directory: \"%s\"", ec.message().c_str() ); - exit(1); + char *envr = SDL_getenv("XDG_CACHE_HOME"); + if (envr) { + ddio_MakePath(Descent3_temp_directory, envr, "Descent3", NULL); + } else { + envr = SDL_getenv("HOME"); + if (envr) { + ddio_MakePath(Descent3_temp_directory, envr, ".cache", "Descent3", NULL); + } else { + std::error_code ec; + std::filesystem::path tempPath = std::filesystem::temp_directory_path(ec); + if (ec) { + Error("Could not find temporary directory: \"%s\"", ec.message().c_str() ); + exit(1); + } + ddio_MakePath(Descent3_temp_directory, tempPath.u8string().c_str(), "Descent3", + "cache", NULL); + } } - ddio_MakePath(Descent3_temp_directory, tempPath.u8string().c_str(), "Descent3", - "cache", NULL); } std::error_code ec;