| 1 |
Description: Write temporary data to $XDG_CACHE_HOME |
| 2 |
From: Sébastien Noel <[email protected]> |
| 3 |
Forwarded: https://github.com/DescentDevelopers/Descent3/pull/625 |
| 4 |
--- a/Descent3/init.cpp |
| 5 |
+++ b/Descent3/init.cpp |
| 6 |
@@ -2002,14 +2002,24 @@ void SetupTempDirectory(void) { |
| 7 |
if (t_arg) { |
| 8 |
strcpy(Descent3_temp_directory, GameArgs[t_arg + 1]); |
| 9 |
} else { |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
+ char *envr = SDL_getenv("XDG_CACHE_HOME"); |
| 16 |
+ if (envr) { |
| 17 |
+ ddio_MakePath(Descent3_temp_directory, envr, "Descent3", NULL); |
| 18 |
+ } else { |
| 19 |
+ envr = SDL_getenv("HOME"); |
| 20 |
+ if (envr) { |
| 21 |
+ ddio_MakePath(Descent3_temp_directory, envr, ".cache", "Descent3", NULL); |
| 22 |
+ } else { |
| 23 |
+ std::error_code ec; |
| 24 |
+ std::filesystem::path tempPath = std::filesystem::temp_directory_path(ec); |
| 25 |
+ if (ec) { |
| 26 |
+ Error("Could not find temporary directory: \"%s\"", ec.message().c_str() ); |
| 27 |
+ exit(1); |
| 28 |
+ } |
| 29 |
+ ddio_MakePath(Descent3_temp_directory, tempPath.u8string().c_str(), "Descent3", |
| 30 |
+ "cache", NULL); |
| 31 |
+ } |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
std::error_code ec; |