Use TMPDIR as a fallback if set

This commit is contained in:
Přemysl Eric Janouch 2016-03-13 00:59:28 +01:00
parent df395f32e5
commit e11ca7cc00
1 changed files with 3 additions and 0 deletions

View File

@ -77,8 +77,11 @@ resolve_relative_runtime_unique_filename (const char *filename)
str_init (&path);
const char *runtime_dir = getenv ("XDG_RUNTIME_DIR");
const char *tmpdir = getenv ("TMPDIR");
if (runtime_dir && *runtime_dir == '/')
str_append (&path, runtime_dir);
else if (tmpdir && *tmpdir == '/')
str_append (&path, tmpdir);
else
str_append (&path, "/tmp");
str_append_printf (&path, "/%s/%s", PROGRAM_NAME, filename);