aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport/pathstuff.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdbsupport/pathstuff.h')
-rw-r--r--gdbsupport/pathstuff.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
index f6c51e9..c859279 100644
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -21,6 +21,7 @@
#define COMMON_PATHSTUFF_H
#include "gdbsupport/byte-vector.h"
+#include "gdbsupport/array-view.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -60,6 +61,28 @@ extern std::string gdb_abspath (const char *path);
extern const char *child_path (const char *parent, const char *child);
+/* Join elements in PATHS into a single path.
+
+ The first element can be absolute or relative. All the others must be
+ relative. */
+
+extern std::string path_join (gdb::array_view<const gdb::string_view> paths);
+
+/* Same as the above, but accept paths as distinct parameters. */
+
+template<typename ...Args>
+std::string
+path_join (Args... paths)
+{
+ /* It doesn't make sense to join less than two paths. */
+ gdb_static_assert (sizeof... (Args) >= 2);
+
+ std::array<gdb::string_view, sizeof... (Args)> views
+ { gdb::string_view (paths)... };
+
+ return path_join (gdb::array_view<const gdb::string_view> (views));
+}
+
/* Return whether PATH contains a directory separator character. */
extern bool contains_dir_separator (const char *path);