summaryrefslogtreecommitdiff
path: root/libs/ardour/globals.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-03-12 17:44:50 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2015-03-12 17:45:42 -0500
commit9a05a0fbfbc54a68f658b800c10f1a4ebc461f8f (patch)
treee1e15503d5e8184d5c907f77d0c9d7fe3f483968 /libs/ardour/globals.cc
parentb8e9e17fac0c2ef930dd80dc6e63c5213d00018c (diff)
alter config file copying infrastructure so it can be used at a suitable time in the instance's lifetime
Diffstat (limited to 'libs/ardour/globals.cc')
-rw-r--r--libs/ardour/globals.cc70
1 files changed, 39 insertions, 31 deletions
diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc
index 89775a586b..f097ce84f5 100644
--- a/libs/ardour/globals.cc
+++ b/libs/ardour/globals.cc
@@ -244,49 +244,55 @@ lotsa_files_please ()
#endif
}
-int
-ARDOUR::copy_configuration_files (string const & old_dir, string const & new_dir, int old_version)
+static int
+copy_configuration_files (string const & old_dir, string const & new_dir, int old_version)
{
string old_name;
string new_name;
+ /* ensure target directory exists */
+
+ if (g_mkdir_with_parents (new_dir.c_str(), 0755)) {
+ return -1;
+ }
+
if (old_version == 3) {
- old_name = Glib::build_filename (old_dir, "recent");
- new_name = Glib::build_filename (new_dir, "recent");
+ old_name = Glib::build_filename (old_dir, X_("recent"));
+ new_name = Glib::build_filename (new_dir, X_("recent"));
copy_file (old_name, new_name);
/* can only copy ardour.rc - UI config is not compatible */
- old_name = Glib::build_filename (old_dir, "ardour.rc");
- new_name = Glib::build_filename (new_dir, "config");
+ old_name = Glib::build_filename (old_dir, X_("ardour.rc"));
+ new_name = Glib::build_filename (new_dir, X_("config"));
copy_file (old_name, new_name);
/* copy templates and route templates */
- old_name = Glib::build_filename (old_dir, "templates");
- new_name = Glib::build_filename (new_dir, "templates");
+ old_name = Glib::build_filename (old_dir, X_("templates"));
+ new_name = Glib::build_filename (new_dir, X_("templates"));
copy_recurse (old_name, new_name);
- old_name = Glib::build_filename (old_dir, "route_templates");
- new_name = Glib::build_filename (new_dir, "route_templates");
+ old_name = Glib::build_filename (old_dir, X_("route_templates"));
+ new_name = Glib::build_filename (new_dir, X_("route_templates"));
copy_recurse (old_name, new_name);
/* presets */
- old_name = Glib::build_filename (old_dir, "presets");
- new_name = Glib::build_filename (new_dir, "presets");
+ old_name = Glib::build_filename (old_dir, X_("presets"));
+ new_name = Glib::build_filename (new_dir, X_("presets"));
copy_recurse (old_name, new_name);
/* presets */
- old_name = Glib::build_filename (old_dir, "plugin_statuses");
- new_name = Glib::build_filename (new_dir, "plugin_statuses");
+ old_name = Glib::build_filename (old_dir, X_("plugin_statuses"));
+ new_name = Glib::build_filename (new_dir, X_("plugin_statuses"));
copy_file (old_name, new_name);
@@ -297,7 +303,7 @@ ARDOUR::copy_configuration_files (string const & old_dir, string const & new_dir
vector<string> export_formats;
g_mkdir_with_parents (Glib::build_filename (new_dir, export_formats_dir_name).c_str(), 0755);
- find_files_matching_pattern (export_formats, old_name, "*.format");
+ find_files_matching_pattern (export_formats, old_name, X_("*.format"));
for (vector<string>::iterator i = export_formats.begin(); i != export_formats.end(); ++i) {
std::string from = *i;
std::string to = Glib::build_filename (new_name, Glib::path_get_basename (*i));
@@ -308,28 +314,32 @@ ARDOUR::copy_configuration_files (string const & old_dir, string const & new_dir
return 0;
}
-static void
-maybe_copy_old_configuration_files ()
+int
+ARDOUR::check_for_old_configuration_files (boost::function<bool (std::string const&, std::string const&, int)> ui_handler)
{
- int version = atoi (X_(PROGRAM_VERSION));
-
- if (version <= 1) {
- return;
+ int current_version = atoi (X_(PROGRAM_VERSION));
+
+ if (current_version <= 1) {
+ return 0;
}
- version--;
+ int old_version = current_version - 1;
- string old_config_dir = user_config_directory (version);
+ string old_config_dir = user_config_directory (old_version);
+ /* pass in the current version explicitly to avoid creation */
+ string current_config_dir = user_config_directory (current_version);
- if (Glib::file_test (old_config_dir, Glib::FILE_TEST_IS_DIR)) {
- string current_config_dir = user_config_directory ();
- boost::optional<bool> r = CopyConfigurationFiles (old_config_dir, current_config_dir, version); /* EMIT SIGNAL */
- if (r) {
- if (r.get()) {
- copy_configuration_files (old_config_dir, current_config_dir, version);
+ if (!Glib::file_test (current_config_dir, Glib::FILE_TEST_IS_DIR)) {
+ if (Glib::file_test (old_config_dir, Glib::FILE_TEST_IS_DIR)) {
+
+ if (ui_handler (old_config_dir, current_config_dir, old_version)) {
+ copy_configuration_files (old_config_dir, current_config_dir, old_version);
+ return 1;
}
}
}
+
+ return 0;
}
bool
@@ -378,8 +388,6 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir
// allow ardour the absolute maximum number of open files
lotsa_files_please ();
- maybe_copy_old_configuration_files ();
-
#ifdef HAVE_LRDF
lrdf_init();
#endif