diff --git a/libs/ardour/ardour/directory_names.h b/libs/ardour/ardour/directory_names.h index 17532e2a3a..db3fc1d533 100644 --- a/libs/ardour/ardour/directory_names.h +++ b/libs/ardour/ardour/directory_names.h @@ -40,7 +40,6 @@ namespace ARDOUR { LIBARDOUR_API extern const char* const route_templates_dir_name; LIBARDOUR_API extern const char* const surfaces_dir_name; LIBARDOUR_API extern const char* const ladspa_dir_name; - LIBARDOUR_API extern const char* const user_config_dir_name; LIBARDOUR_API extern const char* const panner_dir_name; LIBARDOUR_API extern const char* const backend_dir_name; diff --git a/libs/ardour/ardour/filesystem_paths.h b/libs/ardour/ardour/filesystem_paths.h index a6ca2d1c77..82b84f5424 100644 --- a/libs/ardour/ardour/filesystem_paths.h +++ b/libs/ardour/ardour/filesystem_paths.h @@ -27,11 +27,16 @@ namespace ARDOUR { /** - * @return the path to the directory used to store user specific ardour - * configuration files. + * @return the path to the directory used to store user specific + * configuration files for the given @param version of the program. + * If @param version is negative, the build-time string PROGRAM_VERSION + * will be used to determine the version number. + * * @post user_config_directory() exists + * + * */ - LIBARDOUR_API std::string user_config_directory (); + LIBARDOUR_API std::string user_config_directory (int version = -1); /** * @return the path to the directory used to store user specific diff --git a/libs/ardour/directory_names.cc b/libs/ardour/directory_names.cc index 43238ba45a..a5d7bbbe9b 100644 --- a/libs/ardour/directory_names.cc +++ b/libs/ardour/directory_names.cc @@ -40,12 +40,4 @@ const char* const ladspa_dir_name = X_("ladspa"); const char* const panner_dir_name = X_("panners"); const char* const backend_dir_name = X_("backends"); -char config_dir_name[] = X_(PROGRAM_NAME PROGRAM_VERSION); -#if defined (__APPLE__) || defined (PLATFORM_WINDOWS) -const char* const user_config_dir_name = config_dir_name; -#else -#include "pbd/convert.h" -const char* const user_config_dir_name = PBD::downcase (config_dir_name); -#endif - } diff --git a/libs/ardour/filesystem_paths.cc b/libs/ardour/filesystem_paths.cc index c0766c066f..c07acb0280 100644 --- a/libs/ardour/filesystem_paths.cc +++ b/libs/ardour/filesystem_paths.cc @@ -19,8 +19,9 @@ #include #include -#include "pbd/error.h" #include "pbd/compose.h" +#include "pbd/convert.h" +#include "pbd/error.h" #include #include @@ -41,8 +42,24 @@ namespace ARDOUR { using std::string; +static std::string +user_config_directory_name (int version = -1) +{ + if (version < 0) { + version = atoi (X_(PROGRAM_VERSION)); + } + + const string config_dir_name = string_compose ("%1%2", X_(PROGRAM_NAME), version); + +#if defined (__APPLE__) || defined (PLATFORM_WINDOWS) + return config_dir_name; +#else + return downcase (config_dir_name); +#endif +} + std::string -user_config_directory () +user_config_directory (int version) { static std::string p; @@ -79,7 +96,7 @@ user_config_directory () } #endif // end not __APPLE__ - p = Glib::build_filename (p, user_config_dir_name); + p = Glib::build_filename (p, user_config_directory_name (version)); if (!Glib::file_test (p, Glib::FILE_TEST_EXISTS)) { if (g_mkdir_with_parents (p.c_str(), 0755)) { @@ -134,7 +151,7 @@ user_cache_directory () } #endif // end not __APPLE__ - p = Glib::build_filename (p, user_config_dir_name); + p = Glib::build_filename (p, user_config_directory_name ()); #ifdef PLATFORM_WINDOWS /* On Windows Glib::get_user_data_dir is the folder to use for local