summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2020-10-02 17:45:01 +0000
committerColin Walters <walters@verbum.org>2020-10-02 17:45:01 +0000
commit1dd01d5ef172fbe7cb385c91ee2a3740962e8074 (patch)
treeb3f33c67f8d4d227fa63577bf4c1ce4adb609fd0
parent5ef78bb9d968e5f589eba1de31dbae8f9909cd08 (diff)
parenta5b76690b1c351cee5aede6e1a476bd955d1b00c (diff)
downloadlibglnx-1dd01d5ef172fbe7cb385c91ee2a3740962e8074.tar.gz
Merge branch 'tmpfile-dir' into 'master'
glnx-fdio: try $TMPDIR if /var/tmp doesn't exist See merge request GNOME/libglnx!20
-rw-r--r--glnx-fdio.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/glnx-fdio.c b/glnx-fdio.c
index e537a9b..422bc2d 100644
--- a/glnx-fdio.c
+++ b/glnx-fdio.c
@@ -303,8 +303,8 @@ glnx_open_anonymous_tmpfile_full (int flags,
}
/* A variant of `glnx_open_tmpfile_linkable_at()` which doesn't support linking.
- * Useful for true temporary storage. The fd will be allocated in /var/tmp to
- * ensure maximum storage space.
+ * Useful for true temporary storage. The fd will be allocated in `$TMPDIR` if
+ * set or `/var/tmp` otherwise.
*
* If you need the file on a specific filesystem use glnx_open_anonymous_tmpfile_full()
* which lets you pass a directory.
@@ -314,7 +314,10 @@ glnx_open_anonymous_tmpfile (int flags,
GLnxTmpfile *out_tmpf,
GError **error)
{
- return glnx_open_anonymous_tmpfile_full (flags, "/var/tmp", out_tmpf, error);
+ return glnx_open_anonymous_tmpfile_full (flags,
+ getenv("TMPDIR") ?: "/var/tmp",
+ out_tmpf,
+ error);
}
/* Use this after calling glnx_open_tmpfile_linkable_at() to give