+int
+ARDOUR::copy_configuration_files (string const & old_dir, string const & new_dir, int old_version)
+{
+ string old_name;
+ string new_name;
+
+ if (old_version == 3) {
+
+ old_name = Glib::build_filename (old_dir, "recent");
+ new_name = Glib::build_filename (new_dir, "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");
+
+ 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");
+
+ copy_recurse (old_name, new_name);
+
+ old_name = Glib::build_filename (old_dir, "route_templates");
+ new_name = Glib::build_filename (new_dir, "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");
+
+ 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");
+
+ copy_file (old_name, new_name);
+
+ /* export formats */
+
+ old_name = Glib::build_filename (old_dir, export_formats_dir_name);
+ new_name = Glib::build_filename (new_dir, export_formats_dir_name);
+
+ 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");
+ 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));
+ copy_file (from, to);
+ }
+ }
+
+ return 0;
+}
+
+static void
+maybe_copy_old_configuration_files ()
+{
+ int version = atoi (X_(PROGRAM_VERSION));
+
+ if (version <= 1) {
+ return;
+ }
+
+ version--;
+
+ string old_config_dir = user_config_directory (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);
+ }
+ }
+ }
+}
+