From 2974c82428b5d9d3e1f504ba4052aec47fc2b415 Mon Sep 17 00:00:00 2001 From: "John (J5) Palmieri" Date: Thu, 10 Aug 2006 20:09:43 +0000 Subject: * dbus/dbus-sysdeps.c: * dbus/dbus-address.c: * bus/activation.c: * test/shell-test.c: don't hardcode tmp directory (patch from Dave Meikle ) --- dbus/dbus-sysdeps.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'dbus/dbus-sysdeps.c') 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 */ -- cgit