summaryrefslogtreecommitdiff
path: root/libs/ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-03-27 01:04:59 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-03-27 01:04:59 +0000
commit948caba5889a7425cbca11c2eb339f27f5a27194 (patch)
treed8e59f5d2487abb502a28256319147de707968d7 /libs/ardour/utils.cc
parentee7c3042bdb870ea073b69a625b48e30bd6dab94 (diff)
total reimplementation of Configuration object internals to make adding new config vars an order of magnitude simpler. the actual path taken is a bit of a kludge, to put it mildly, but adding a new variable is now basically just one line in configuration_vars.h, and no work is required for serialization to/from ardour.rc.
git-svn-id: svn://localhost/trunk/ardour2@420 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r--libs/ardour/utils.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index 003e1c92a3..a5b0b4f2ce 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -30,6 +30,10 @@
#include <fcntl.h>
#include <unistd.h>
+#ifdef HAVE_WORDEXP
+#include <wordexp.h>
+#endif
+
#include <pbd/error.h>
#include <pbd/xml++.h>
#include <ardour/utils.h>
@@ -222,3 +226,34 @@ region_name_from_path (string path)
return path;
}
+
+string
+path_expand (string path)
+{
+#ifdef HAVE_WORDEXP
+ /* Handle tilde and environment variable expansion in session path */
+ string ret = path;
+
+ wordexp_t expansion;
+ switch (wordexp (path.c_str(), &expansion, WRDE_NOCMD|WRDE_UNDEF)) {
+ case 0:
+ break;
+ default:
+ error << string_compose (_("illegal or badly-formed string used for path (%1)"), path) << endmsg;
+ goto out;
+ }
+
+ if (expansion.we_wordc > 1) {
+ error << string_compose (_("path (%1) is ambiguous"), path) << endmsg;
+ goto out;
+ }
+
+ ret = expansion.we_wordv[0];
+ out:
+ wordfree (&expansion);
+ return ret;
+
+#else
+ return path;
+#endif
+}