Add ARDOUR::config_search_path
authorTim Mayberry <mojofunk@gmail.com>
Wed, 27 Jun 2007 12:12:26 +0000 (12:12 +0000)
committerTim Mayberry <mojofunk@gmail.com>
Wed, 27 Jun 2007 12:12:26 +0000 (12:12 +0000)
git-svn-id: svn://localhost/ardour2/trunk@2053 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/filesystem_paths.h
libs/ardour/filesystem_paths.cc

index 9d7d6ba21655dd3467f695ae12d7d7b85db767c5..c5b8b2a057f1bf4c8cb1ddcbcc1b737458763517 100644 (file)
 #define ARDOUR_FILESYSTEM_PATHS_INCLUDED
 
 #include <pbd/filesystem.h>
+#include <pbd/search_path.h>
 
 namespace ARDOUR {
 
        using namespace PBD;
-       
+
        /**
         * @return the path to the directory used to store user specific ardour
         * configuration files.
@@ -38,6 +39,8 @@ namespace ARDOUR {
         */
        sys::path ardour_module_directory ();
 
+       SearchPath config_search_path ();
+
 } // namespace ARDOUR
 
 #endif
index 5ce4f4f7ed16036154e2a8e5c9503a77fb5e2f49..e41b9954cfb01d2696ce80bb8313331147d558e0 100644 (file)
 */
 
 #include <pbd/error.h>
+#include <pbd/filesystem_paths.h>
 
 #include <glibmm/miscutils.h>
 
 #include <ardour/directory_names.h>
 #include <ardour/filesystem_paths.h>
 
+#define WITH_STATIC_PATHS 1
+
+namespace {
+       const char * const config_env_variable_name = "ARDOUR_CONFIG_PATH";
+}
+
 namespace ARDOUR {
 
 using std::string;
@@ -57,4 +64,30 @@ ardour_module_directory ()
        return module_directory;
 }
 
+SearchPath
+config_search_path ()
+{
+       bool config_path_defined = false;
+       SearchPath spath_env(Glib::getenv(config_env_variable_name, config_path_defined));
+
+       if (config_path_defined)
+       {
+               return spath_env;
+       }
+
+#ifdef WITH_STATIC_PATHS
+
+       SearchPath spath(string(CONFIG_DIR));
+
+#else
+
+       SearchPath spath(system_config_directories());
+
+#endif
+
+       spath.add_subdirectory_to_paths("ardour2");
+
+       return spath;
+}
+
 } // namespace ARDOUR