From bbc289dbe3d6d9894c5db2d7a362409ae8a25578 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 27 Jun 2007 12:12:28 +0000 Subject: [PATCH] Add ARDOUR::ardour_search_path that contains the directories in the ARDOUR_PATH environment variable. Rename ARDOUR::config_search_path to ARDOUR::system_config_search_path Use PBD::find_file_in_search_path in Configuration::load_state git-svn-id: svn://localhost/ardour2/trunk@2054 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/filesystem_paths.h | 4 +++- libs/ardour/configuration.cc | 27 +++++++++++++++------------ libs/ardour/filesystem_paths.cc | 27 +++++++++++---------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/libs/ardour/ardour/filesystem_paths.h b/libs/ardour/ardour/filesystem_paths.h index c5b8b2a057..b5ef1a91c9 100644 --- a/libs/ardour/ardour/filesystem_paths.h +++ b/libs/ardour/ardour/filesystem_paths.h @@ -39,7 +39,9 @@ namespace ARDOUR { */ sys::path ardour_module_directory (); - SearchPath config_search_path (); + SearchPath ardour_search_path (); + + SearchPath system_config_search_path (); } // namespace ARDOUR diff --git a/libs/ardour/configuration.cc b/libs/ardour/configuration.cc index 2c0143cdba..903f853ef5 100644 --- a/libs/ardour/configuration.cc +++ b/libs/ardour/configuration.cc @@ -23,8 +23,8 @@ #include #include #include +#include -#include #include #include #include @@ -80,17 +80,18 @@ Configuration::load_state () { bool found = false; - string rcfile; + sys::path system_rc_file; /* load system configuration first */ - - rcfile = find_config_file ("ardour_system.rc"); - - if (rcfile.length()) { - + + if ( find_file_in_search_path (ardour_search_path() + system_config_search_path(), + "ardour_system.rc", system_rc_file) ) + { XMLTree tree; found = true; + string rcfile = system_rc_file.to_string(); + cerr << string_compose (_("loading system configuration file %1"), rcfile) << endl; if (!tree.read (rcfile.c_str())) { @@ -106,16 +107,18 @@ Configuration::load_state () } } - /* now load configuration file for user */ - - rcfile = find_config_file ("ardour.rc"); - if (rcfile.length()) { + sys::path user_rc_file; + if (find_file_in_search_path (ardour_search_path() + user_config_directory(), + "ardour.rc", user_rc_file)) + { XMLTree tree; found = true; - + + string rcfile = user_rc_file.to_string(); + cerr << string_compose (_("loading user configuration file %1"), rcfile) << endl; if (!tree.read (rcfile)) { diff --git a/libs/ardour/filesystem_paths.cc b/libs/ardour/filesystem_paths.cc index e41b9954cf..69b00393a8 100644 --- a/libs/ardour/filesystem_paths.cc +++ b/libs/ardour/filesystem_paths.cc @@ -27,10 +27,6 @@ #define WITH_STATIC_PATHS 1 -namespace { - const char * const config_env_variable_name = "ARDOUR_CONFIG_PATH"; -} - namespace ARDOUR { using std::string; @@ -65,29 +61,28 @@ ardour_module_directory () } SearchPath -config_search_path () +ardour_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; - } + SearchPath spath_env(Glib::getenv("ARDOUR_PATH")); + return spath_env; +} +SearchPath +system_config_search_path () +{ #ifdef WITH_STATIC_PATHS - SearchPath spath(string(CONFIG_DIR)); + SearchPath config_path(string(CONFIG_DIR)); #else - SearchPath spath(system_config_directories()); + SearchPath config_path(system_config_directories()); #endif - spath.add_subdirectory_to_paths("ardour2"); + config_path.add_subdirectory_to_paths("ardour2"); - return spath; + return config_path; } } // namespace ARDOUR