summaryrefslogtreecommitdiff
path: root/libs/pbd/search_path.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-03-02 11:25:54 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2014-03-02 11:25:54 -0500
commit8040df189775fdbcfe842cc192228955ec357774 (patch)
tree06a1ffec06fddbd2620baf1ff4897a00299721b0 /libs/pbd/search_path.cc
parentb8419ae7cdf55c4bce8a0ce9b102c2edd6dd0d1f (diff)
move export_search_path(), previously in gtk2_ardour/main.cc, into libs/pbd
Diffstat (limited to 'libs/pbd/search_path.cc')
-rw-r--r--libs/pbd/search_path.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/pbd/search_path.cc b/libs/pbd/search_path.cc
index 0106881f84..fe2087f6b1 100644
--- a/libs/pbd/search_path.cc
+++ b/libs/pbd/search_path.cc
@@ -17,6 +17,9 @@
*/
+#include <string>
+
+#include <glib.h>
#include <glibmm/miscutils.h>
#include "pbd/tokenizer.h"
@@ -118,4 +121,26 @@ Searchpath::add_subdirectory_to_paths (const string& subdir)
return *this;
}
+/* This is not part of the Searchpath object, but is closely related to the
+ * whole idea, and we put it here for convenience.
+ */
+
+void
+export_search_path (const string& base_dir, const char* varname, const char* dir)
+{
+ string path;
+ const char * cstr = g_getenv (varname);
+
+ if (cstr) {
+ path = cstr;
+ path += ':';
+ } else {
+ path = "";
+ }
+ path += base_dir;
+ path += dir;
+
+ g_setenv (varname, path.c_str(), 1);
+}
+
} // namespace PBD