X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Ffilesystem_paths.cc;h=73bfaff137f726c0b9854d9516d552ebf8d7e958;hb=5e1cfcc7ed557fc28ca8b362deceefa1967ab22b;hp=760b16c40946f11daba4e67724f7f7d8f592f805;hpb=5b1da330a4eedcece28cc5e040c90663b8b607d5;p=ardour.git diff --git a/libs/ardour/filesystem_paths.cc b/libs/ardour/filesystem_paths.cc index 760b16c409..73bfaff137 100644 --- a/libs/ardour/filesystem_paths.cc +++ b/libs/ardour/filesystem_paths.cc @@ -21,7 +21,6 @@ #include "pbd/error.h" #include "pbd/compose.h" -#include "pbd/strsplit.h" #include #include @@ -37,15 +36,15 @@ namespace ARDOUR { using std::string; -sys::path +std::string user_config_directory () { - sys::path p; + static std::string p; -#ifdef __APPLE__ - p = Glib::get_home_dir(); - p /= "Library/Preferences"; + if (!p.empty()) return p; +#ifdef __APPLE__ + p = Glib::build_filename (Glib::get_home_dir(), "Library/Preferences"); #else const char* c = 0; @@ -58,39 +57,33 @@ user_config_directory () const string home_dir = Glib::get_home_dir(); if (home_dir.empty ()) { - const string error_msg = "Unable to determine home directory"; - - // log the error - error << error_msg << endmsg; - - throw sys::filesystem_error(error_msg); + error << "Unable to determine home directory" << endmsg; + exit (1); } p = home_dir; - p /= ".config"; + p = Glib::build_filename (p, ".config"); } #endif - p /= user_config_dir_name; + p = Glib::build_filename (p, user_config_dir_name); - std::string ps (p.to_string()); - - if (!Glib::file_test (ps, Glib::FILE_TEST_EXISTS)) { - if (g_mkdir_with_parents (ps.c_str(), 0755)) { + if (!Glib::file_test (p, Glib::FILE_TEST_EXISTS)) { + if (g_mkdir_with_parents (p.c_str(), 0755)) { error << string_compose (_("Cannot create Configuration directory %1 - cannot run"), - ps) << endmsg; + p) << endmsg; exit (1); } - } else if (!Glib::file_test (ps, Glib::FILE_TEST_IS_DIR)) { + } else if (!Glib::file_test (p, Glib::FILE_TEST_IS_DIR)) { error << string_compose (_("Configuration directory %1 already exists and is not a directory/folder - cannot run"), - ps) << endmsg; + p) << endmsg; exit (1); } return p; } -sys::path +std::string ardour_dll_directory () { std::string s = Glib::getenv("ARDOUR_DLL_PATH"); @@ -98,17 +91,16 @@ ardour_dll_directory () std::cerr << _("ARDOUR_DLL_PATH not set in environment - exiting\n"); ::exit (1); } - return sys::path (s); + return s; } SearchPath ardour_config_search_path () { - static bool have_path = false; static SearchPath search_path; - if (!have_path) { - SearchPath sp (user_config_directory()); + if (search_path.empty()) { + search_path += user_config_directory(); std::string s = Glib::getenv("ARDOUR_CONFIG_PATH"); if (s.empty()) { @@ -116,14 +108,7 @@ ardour_config_search_path () ::exit (1); } - std::vector ss; - split (s, ss, ':'); - for (std::vector::iterator i = ss.begin(); i != ss.end(); ++i) { - sp += sys::path (*i); - } - - search_path = sp; - have_path = true; + search_path += SearchPath (s); } return search_path; @@ -132,11 +117,10 @@ ardour_config_search_path () SearchPath ardour_data_search_path () { - static bool have_path = false; static SearchPath search_path; - if (!have_path) { - SearchPath sp (user_config_directory()); + if (search_path.empty()) { + search_path += user_config_directory(); std::string s = Glib::getenv("ARDOUR_DATA_PATH"); if (s.empty()) { @@ -144,14 +128,7 @@ ardour_data_search_path () ::exit (1); } - std::vector ss; - split (s, ss, ':'); - for (std::vector::iterator i = ss.begin(); i != ss.end(); ++i) { - sp += sys::path (*i); - } - - search_path = sp; - have_path = true; + search_path += SearchPath (s); } return search_path;