aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-09-14 11:28:45 -0600
committerTom Tromey <tom@tromey.com>2018-10-27 11:58:40 -0600
commit29be4d9dee1263b36e33421dd8ea69b9b7308391 (patch)
tree17db04186271dfff6b2816d044bf23672687a66f /gdb/common
parent974e68446388769f023c6c9bfb1e67ed75199618 (diff)
downloadgdb-29be4d9dee1263b36e33421dd8ea69b9b7308391.zip
gdb-29be4d9dee1263b36e33421dd8ea69b9b7308391.tar.gz
gdb-29be4d9dee1263b36e33421dd8ea69b9b7308391.tar.bz2
Move make_temp_filename to common/pathstuff.c
Currently make_temp_filename is a function local to write_psymtabs_to_index. This patch moves it to pathstuff.c so that it can be used from other places in gdb. gdb/ChangeLog 2018-10-27 Tom Tromey <tom@tromey.com> * dwarf-index-write.c (write_psymtabs_to_index): Move make_temp_filename to common/pathstuff.c. * common/pathstuff.h (make_temp_filename): Declare. * common/pathstuff.c (make_temp_filename): New function, moved from dwarf-index-write.c.
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/pathstuff.c11
-rw-r--r--gdb/common/pathstuff.h7
2 files changed, 18 insertions, 0 deletions
diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c
index 6d8e53f..48ff861 100644
--- a/gdb/common/pathstuff.c
+++ b/gdb/common/pathstuff.c
@@ -202,3 +202,14 @@ get_shell ()
return ret;
}
+
+/* See common/pathstuff.h. */
+
+gdb::char_vector
+make_temp_filename (const std::string &f)
+{
+ gdb::char_vector filename_temp (f.length () + 8);
+ strcpy (filename_temp.data (), f.c_str ());
+ strcat (filename_temp.data () + f.size (), "-XXXXXX");
+ return filename_temp;
+}
diff --git a/gdb/common/pathstuff.h b/gdb/common/pathstuff.h
index 0a8caea..d57aaff 100644
--- a/gdb/common/pathstuff.h
+++ b/gdb/common/pathstuff.h
@@ -20,6 +20,8 @@
#ifndef PATHSTUFF_H
#define PATHSTUFF_H
+#include "common/byte-vector.h"
+
/* Path utilities. */
/* Return the real path of FILENAME, expanding all the symbolic links.
@@ -69,4 +71,9 @@ extern std::string get_standard_cache_dir ();
extern const char *get_shell ();
+/* Make a filename suitable to pass to mkstemp based on F (e.g.
+ /tmp/foo -> /tmp/foo-XXXXXX). */
+
+extern gdb::char_vector make_temp_filename (const std::string &f);
+
#endif /* PATHSTUFF_H */