summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-sysdeps.c
diff options
context:
space:
mode:
Diffstat (limited to 'dbus/dbus-sysdeps.c')
-rw-r--r--dbus/dbus-sysdeps.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
index 9a2c1fde..43bfcd8c 100644
--- a/dbus/dbus-sysdeps.c
+++ b/dbus/dbus-sysdeps.c
@@ -2998,6 +2998,35 @@ int _dbus_printf_string_upper_bound (const char *format,
+/**
+ * Gets the temporary files directory by inspecting the environment variables
+ * TMPDIR, TMP, and TEMP in that order. If none of those are set "/tmp" is returned
+ *
+ * @returns char* - location of temp directory
+ */
+char*
+_dbus_get_tmpdir()
+{
+ char* tmpdir;
+
+ tmpdir = getenv("TMPDIR");
+ if (tmpdir) {
+ return tmpdir;
+ }
+
+ tmpdir = getenv("TMP");
+ if (tmpdir) {
+ return tmpdir;
+ }
+
+ tmpdir = getenv("TEMP");
+ if (tmpdir) {
+ return tmpdir;
+ }
+
+ return "/tmp";
+}
+
/** @} end of sysdeps */
/* tests in dbus-sysdeps-util.c */