This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 3/6] Move mkdir_recursive to common/filestuff.c
On 2018-10-30 4:55 p.m., Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:
>
> Simon> What do you think about this?
>
> Thanks for doing this.
>
> Simon> /* See common/pathstuff.h. */
>
> Simon> +std::string
> Simon> +get_standard_temp_dir ()
> Simon> +{
> Simon> +#ifdef WIN32
> Simon> + char *tmp = getenv ("TMP");
> Simon> + if (tmp != nullptr)
> Simon> + return tmp;
> Simon> +
> Simon> + tmp = getenv ("TEMP");
> Simon> + if (tmp != nullptr)
> Simon> + return tmp;
> Simon> +
> Simon> + error (_("Couldn't find temp dir path, both TMP and TEMP are unset."));
> Simon> +
> Simon> +#else
> Simon> + return "/tmp";
>
> It would be normal to look at TMPDIR on unix systems.
Ah, indeed. How is it with this little fixup on top of the patch?
From e8b9d0eabfb9bd85afcf42af9bdfb6a5bde66fc2 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Tue, 30 Oct 2018 17:01:50 -0400
Subject: [PATCH] fixup
---
gdb/common/pathstuff.c | 4 ++++
gdb/common/pathstuff.h | 5 +++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c
index c0c575f3fb4..166a21593eb 100644
--- a/gdb/common/pathstuff.c
+++ b/gdb/common/pathstuff.c
@@ -208,6 +208,10 @@ get_standard_temp_dir ()
error (_("Couldn't find temp dir path, both TMP and TEMP are unset."));
#else
+ char *tmp = getenv ("TMPDIR");
+ if (tmp != nullptr)
+ return tmp;
+
return "/tmp";
#endif
}
diff --git a/gdb/common/pathstuff.h b/gdb/common/pathstuff.h
index 18af733ab98..f29349e8b28 100644
--- a/gdb/common/pathstuff.h
+++ b/gdb/common/pathstuff.h
@@ -68,8 +68,9 @@ extern std::string get_standard_cache_dir ();
/* Get the usual temporary directory for the current platform.
- On Windows, this is the TMP or TEMP environment variable. On the rest,
- it's /tmp.
+ On Windows, this is the TMP or TEMP environment variable.
+
+ On the rest, this is the TMPDIR environment variable, if defined, else /tmp.
Throw an exception on error. */
--
2.19.1