diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/ardour.h | 5 | ||||
-rw-r--r-- | libs/ardour/ardour/configuration.h | 3 | ||||
-rw-r--r-- | libs/ardour/audio_library.cc | 4 | ||||
-rw-r--r-- | libs/ardour/configuration.cc | 73 | ||||
-rw-r--r-- | libs/ardour/globals.cc | 74 | ||||
-rw-r--r-- | libs/ardour/recent_sessions.cc | 4 | ||||
-rw-r--r-- | libs/ardour/session.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 10 |
8 files changed, 73 insertions, 102 deletions
diff --git a/libs/ardour/ardour/ardour.h b/libs/ardour/ardour/ardour.h index 293d346823..45b45ecd06 100644 --- a/libs/ardour/ardour/ardour.h +++ b/libs/ardour/ardour/ardour.h @@ -47,6 +47,11 @@ namespace ARDOUR { int init (AudioEngine&, bool with_vst, bool try_optimization, void (*sighandler)(int,siginfo_t*,void*) = 0); int cleanup (); + + + std::string get_user_ardour_path (); + std::string get_system_ardour_path (); + std::string find_config_file (std::string name); std::string find_data_file (std::string name, std::string subdir = "" ); diff --git a/libs/ardour/ardour/configuration.h b/libs/ardour/ardour/configuration.h index 8ae0c0f73a..7fe3b31232 100644 --- a/libs/ardour/ardour/configuration.h +++ b/libs/ardour/ardour/configuration.h @@ -161,9 +161,6 @@ class Configuration : public Stateful bool get_timecode_source_is_synced (); void set_timecode_source_is_synced (bool); - std::string get_user_ardour_path (); - std::string get_system_ardour_path (); - gain_t get_quieten_at_speed (); void set_quieten_at_speed (gain_t); diff --git a/libs/ardour/audio_library.cc b/libs/ardour/audio_library.cc index 33a1ad230e..bf462f7128 100644 --- a/libs/ardour/audio_library.cc +++ b/libs/ardour/audio_library.cc @@ -49,11 +49,11 @@ AudioLibrary::AudioLibrary () { // sfdb_paths.push_back("/Users/taybin/sounds"); - src = "file:" + Config->get_user_ardour_path() + "sfdb"; + src = "file:" + get_user_ardour_path() + "sfdb"; // workaround for possible bug in raptor that crashes when saving to a // non-existant file. - touch_file(Config->get_user_ardour_path() + "sfdb"); + touch_file(get_user_ardour_path() + "sfdb"); lrdf_read_file(src.c_str()); diff --git a/libs/ardour/configuration.cc b/libs/ardour/configuration.cc index 3b4ad4b45f..f73ba1052a 100644 --- a/libs/ardour/configuration.cc +++ b/libs/ardour/configuration.cc @@ -59,24 +59,12 @@ Configuration::~Configuration () string Configuration::get_user_path() { - char *envvar; - - if ((envvar = getenv ("ARDOUR_RC")) != 0) { - return envvar; - } - return find_config_file ("ardour.rc"); } string Configuration::get_system_path() { - char* envvar; - - if ((envvar = getenv ("ARDOUR_SYSTEM_RC")) != 0) { - return envvar; - } - return find_config_file ("ardour_system.rc"); } @@ -92,9 +80,7 @@ Configuration::load_state () if (rcfile.length()) { XMLTree tree; - - cerr << "Loading system configuration file " << rcfile << endl; - + if (!tree.read (rcfile.c_str())) { error << string_compose(_("Ardour: cannot read system configuration file \"%1\""), rcfile) << endmsg; return -1; @@ -117,9 +103,7 @@ Configuration::load_state () if (rcfile.length()) { XMLTree tree; - - cerr << "Loading user configuration file " << rcfile << endl; - + if (!tree.read (rcfile)) { error << string_compose(_("Ardour: cannot read configuration file \"%1\""), rcfile) << endmsg; return -1; @@ -140,28 +124,12 @@ Configuration::save_state() { XMLTree tree; string rcfile; - char *envvar; /* Note: this only writes the per-user file, and therefore only saves variables marked as user-set or modified */ - if ((envvar = getenv ("ARDOUR_RC")) != 0) { - if (strlen (envvar) == 0) { - return -1; - } - rcfile = envvar; - } else { - - if ((envvar = getenv ("HOME")) == 0) { - return -1; - } - if (strlen (envvar) == 0) { - return -1; - } - rcfile = envvar; - rcfile += "/.ardour/ardour.rc"; - } + rcfile = find_config_file("ardour.rc"); if (rcfile.length()) { tree.set_root (&state (true)); @@ -1054,41 +1022,6 @@ Configuration::set_auto_xfade (bool yn) } } -string -Configuration::get_user_ardour_path () -{ - string path; - char* envvar; - - if ((envvar = getenv ("HOME")) == 0 || strlen (envvar) == 0) { - return "/"; - } - - path = envvar; - path += "/.ardour/"; - - return path; -} - -string -Configuration::get_system_ardour_path () -{ - string path; - char* envvar; - - if ((envvar = getenv ("ARDOUR_DATA_PATH")) != 0) { - path += envvar; - if (path[path.length()-1] != ':') { - path += ':'; - } - } - - path += DATA_DIR; - path += "/ardour/"; - - return path; -} - bool Configuration::get_no_new_session_dialog() { diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index ad7f5c0cc8..9c3cadafe2 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -32,6 +32,7 @@ #include <lrdf.h> #include <pbd/error.h> +#include <pbd/strsplit.h> #include <midi++/port.h> #include <midi++/port_request.h> @@ -298,37 +299,72 @@ ARDOUR::new_change () return c; } -static string -find_file (string name, string dir, string subdir = "") +string +ARDOUR::get_user_ardour_path () { string path; + char* envvar; + + if ((envvar = getenv ("HOME")) == 0 || strlen (envvar) == 0) { + return "/"; + } + + path = envvar; + path += "/.ardour/"; + + return path; +} - /* stop A: ~/.ardour/... */ - - path = getenv ("HOME"); +string +ARDOUR::get_system_ardour_path () +{ + string path; - if (path.length()) { - - path += "/.ardour/"; + path += DATA_DIR; + path += "/ardour/"; + + return path; +} - /* try to ensure that the directory exists. - failure doesn't mean much here. - */ +static string +find_file (string name, string dir, string subdir = "") +{ + string path; + char* envvar = getenv("ARDOUR_PATH"); - mkdir (path.c_str(), 0755); + /* stop A: any directory in ARDOUR_PATH */ + + if (envvar != 0) { - if (subdir.length()) { - path += subdir + "/"; - } + vector<string> split_path; + + split (envvar, split_path, ':'); - path += name; - if (access (path.c_str(), R_OK) == 0) { - return path; + for (vector<string>::iterator i = split_path.begin(); i != split_path.end(); ++i) { + path = *i; + path += "/" + name; + if (access (path.c_str(), R_OK) == 0) { + cerr << "Using file " << path << " found in ARDOUR_PATH." << endl; + return path; + } } } - /* stop B: dir/... */ + /* stop B: ~/.ardour/ */ + path = get_user_ardour_path(); + + if (subdir.length()) { + path += subdir + "/"; + } + + path += name; + if (access (path.c_str(), R_OK) == 0) { + return path; + } + + /* C: dir/... */ + path = dir; path += "/ardour/"; diff --git a/libs/ardour/recent_sessions.cc b/libs/ardour/recent_sessions.cc index a5c6b210ee..efbdb807f7 100644 --- a/libs/ardour/recent_sessions.cc +++ b/libs/ardour/recent_sessions.cc @@ -34,7 +34,7 @@ using namespace ARDOUR; int ARDOUR::read_recent_sessions (RecentSessions& rs) { - string path = Config->get_user_ardour_path(); + string path = get_user_ardour_path(); path += "/recent"; ifstream recent (path.c_str()); @@ -82,7 +82,7 @@ ARDOUR::read_recent_sessions (RecentSessions& rs) int ARDOUR::write_recent_sessions (RecentSessions& rs) { - string path = Config->get_user_ardour_path(); + string path = get_user_ardour_path(); path += "/recent"; ofstream recent (path.c_str()); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 4361bd244e..9b61b5d816 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -3409,7 +3409,7 @@ void Session::add_instant_xml (XMLNode& node, const std::string& dir) { Stateful::add_instant_xml (node, dir); - Config->add_instant_xml (node, Config->get_user_ardour_path()); + Config->add_instant_xml (node, get_user_ardour_path()); } int diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 241d54c8b6..5bb7ad01e4 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -2241,7 +2241,7 @@ Session::automation_dir () const string Session::template_dir () { - string path = Config->get_user_ardour_path(); + string path = get_user_ardour_path(); path += "templates/"; return path; @@ -2252,11 +2252,11 @@ Session::template_path () { string path; - path += Config->get_user_ardour_path(); + path += get_user_ardour_path(); if (path[path.length()-1] != ':') { path += ':'; } - path += Config->get_system_ardour_path(); + path += get_system_ardour_path(); vector<string> split_path; @@ -2654,7 +2654,7 @@ Session::get_template_list (list<string> &template_names) int Session::read_favorite_dirs (FavoriteDirs & favs) { - string path = Config->get_user_ardour_path(); + string path = get_user_ardour_path(); path += "/favorite_dirs"; ifstream fav (path.c_str()); @@ -2689,7 +2689,7 @@ Session::read_favorite_dirs (FavoriteDirs & favs) int Session::write_favorite_dirs (FavoriteDirs & favs) { - string path = Config->get_user_ardour_path(); + string path = get_user_ardour_path(); path += "/favorite_dirs"; ofstream fav (path.c_str()); |