Create new common/pathstuff.[ch]
[deliverable/binutils-gdb.git] / gdb / common / gdb_tilde_expand.c
index b4f371464dcb5f2a29dbdc0de492d334ad6fd983..fcb97961ac0494632f949896c021d2d89f885e80 100644 (file)
@@ -80,3 +80,16 @@ gdb_tilde_expand (const char *dir)
 
   return expanded_dir;
 }
+
+/* See common/gdb_tilde_expand.h.  */
+
+gdb::unique_xmalloc_ptr<char>
+gdb_tilde_expand_up (const char *dir)
+{
+  gdb_glob glob (dir, GLOB_TILDE_CHECK, NULL);
+
+  gdb_assert (glob.pathc () > 0);
+  /* "glob" may return more than one match to the path provided by the
+     user, but we are only interested in the first match.  */
+  return gdb::unique_xmalloc_ptr<char> (xstrdup (glob.pathv ()[0]));
+}
This page took 0.025516 seconds and 4 git commands to generate.