diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2006-03-12 16:19:03 +0000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2006-03-12 16:19:03 +0000 |
commit | a8640ec0af8a477b35ddfd9b83d8704e63edf978 (patch) | |
tree | 74ef1d33983d911faec6671be963e22f2445e35e /libs/ardour/globals.cc | |
parent | 670641c3df89af73de36efa5b0a184c2430275b0 (diff) |
removed the following environment variables:
ARDOUR_GLADE_PATH
ARDOUR_RC
ARDOUR_UI
ARDOUR_UI_RC
ARDOUR_BINDINGS
ARDOUR_COLORS
They have been replaced with just one environment
variable called ARDOUR_PATH which can contain a number
of colon separated paths that are used to find various
configuration and data files. Files located in
ARDOUR_PATH have priority over files in ~/.ardour/ and
in the system path.
Moved two member functions of the Configuration class
into globals.cc as they should of been static and I'm
trying to keep the non-portable code together when it
makes sense.
git-svn-id: svn://localhost/trunk/ardour2@380 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/globals.cc')
-rw-r--r-- | libs/ardour/globals.cc | 74 |
1 files changed, 55 insertions, 19 deletions
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/"; |