mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 19:56:31 +01:00
alter config file copying infrastructure so it can be used at a suitable time in the instance's lifetime
This commit is contained in:
parent
b8e9e17fac
commit
9a05a0fbfb
2 changed files with 45 additions and 32 deletions
|
|
@ -83,7 +83,12 @@ namespace ARDOUR {
|
||||||
LIBARDOUR_API void setup_fpu ();
|
LIBARDOUR_API void setup_fpu ();
|
||||||
LIBARDOUR_API std::vector<SyncSource> get_available_sync_options();
|
LIBARDOUR_API std::vector<SyncSource> get_available_sync_options();
|
||||||
|
|
||||||
LIBARDOUR_API int copy_configuration_files (std::string const & old_dir, std::string const & new_dir, int old_version);
|
/* the @param ui_handler will be called if there are old configuration
|
||||||
|
* files to be copied. It should (probably) ask the user about the
|
||||||
|
* action, and return true or false depending on whether or not the
|
||||||
|
* copy should take place.
|
||||||
|
*/
|
||||||
|
LIBARDOUR_API int check_for_old_configuration_files (boost::function<bool (std::string const&, std::string const&, int)> ui_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __ardour_ardour_h__ */
|
#endif /* __ardour_ardour_h__ */
|
||||||
|
|
|
||||||
|
|
@ -244,49 +244,55 @@ lotsa_files_please ()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
ARDOUR::copy_configuration_files (string const & old_dir, string const & new_dir, int old_version)
|
copy_configuration_files (string const & old_dir, string const & new_dir, int old_version)
|
||||||
{
|
{
|
||||||
string old_name;
|
string old_name;
|
||||||
string new_name;
|
string new_name;
|
||||||
|
|
||||||
|
/* ensure target directory exists */
|
||||||
|
|
||||||
|
if (g_mkdir_with_parents (new_dir.c_str(), 0755)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (old_version == 3) {
|
if (old_version == 3) {
|
||||||
|
|
||||||
old_name = Glib::build_filename (old_dir, "recent");
|
old_name = Glib::build_filename (old_dir, X_("recent"));
|
||||||
new_name = Glib::build_filename (new_dir, "recent");
|
new_name = Glib::build_filename (new_dir, X_("recent"));
|
||||||
|
|
||||||
copy_file (old_name, new_name);
|
copy_file (old_name, new_name);
|
||||||
|
|
||||||
/* can only copy ardour.rc - UI config is not compatible */
|
/* can only copy ardour.rc - UI config is not compatible */
|
||||||
|
|
||||||
old_name = Glib::build_filename (old_dir, "ardour.rc");
|
old_name = Glib::build_filename (old_dir, X_("ardour.rc"));
|
||||||
new_name = Glib::build_filename (new_dir, "config");
|
new_name = Glib::build_filename (new_dir, X_("config"));
|
||||||
|
|
||||||
copy_file (old_name, new_name);
|
copy_file (old_name, new_name);
|
||||||
|
|
||||||
/* copy templates and route templates */
|
/* copy templates and route templates */
|
||||||
|
|
||||||
old_name = Glib::build_filename (old_dir, "templates");
|
old_name = Glib::build_filename (old_dir, X_("templates"));
|
||||||
new_name = Glib::build_filename (new_dir, "templates");
|
new_name = Glib::build_filename (new_dir, X_("templates"));
|
||||||
|
|
||||||
copy_recurse (old_name, new_name);
|
copy_recurse (old_name, new_name);
|
||||||
|
|
||||||
old_name = Glib::build_filename (old_dir, "route_templates");
|
old_name = Glib::build_filename (old_dir, X_("route_templates"));
|
||||||
new_name = Glib::build_filename (new_dir, "route_templates");
|
new_name = Glib::build_filename (new_dir, X_("route_templates"));
|
||||||
|
|
||||||
copy_recurse (old_name, new_name);
|
copy_recurse (old_name, new_name);
|
||||||
|
|
||||||
/* presets */
|
/* presets */
|
||||||
|
|
||||||
old_name = Glib::build_filename (old_dir, "presets");
|
old_name = Glib::build_filename (old_dir, X_("presets"));
|
||||||
new_name = Glib::build_filename (new_dir, "presets");
|
new_name = Glib::build_filename (new_dir, X_("presets"));
|
||||||
|
|
||||||
copy_recurse (old_name, new_name);
|
copy_recurse (old_name, new_name);
|
||||||
|
|
||||||
/* presets */
|
/* presets */
|
||||||
|
|
||||||
old_name = Glib::build_filename (old_dir, "plugin_statuses");
|
old_name = Glib::build_filename (old_dir, X_("plugin_statuses"));
|
||||||
new_name = Glib::build_filename (new_dir, "plugin_statuses");
|
new_name = Glib::build_filename (new_dir, X_("plugin_statuses"));
|
||||||
|
|
||||||
copy_file (old_name, new_name);
|
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;
|
vector<string> export_formats;
|
||||||
g_mkdir_with_parents (Glib::build_filename (new_dir, export_formats_dir_name).c_str(), 0755);
|
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) {
|
for (vector<string>::iterator i = export_formats.begin(); i != export_formats.end(); ++i) {
|
||||||
std::string from = *i;
|
std::string from = *i;
|
||||||
std::string to = Glib::build_filename (new_name, Glib::path_get_basename (*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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
int
|
||||||
maybe_copy_old_configuration_files ()
|
ARDOUR::check_for_old_configuration_files (boost::function<bool (std::string const&, std::string const&, int)> ui_handler)
|
||||||
{
|
{
|
||||||
int version = atoi (X_(PROGRAM_VERSION));
|
int current_version = atoi (X_(PROGRAM_VERSION));
|
||||||
|
|
||||||
if (version <= 1) {
|
if (current_version <= 1) {
|
||||||
return;
|
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 (current_config_dir, Glib::FILE_TEST_IS_DIR)) {
|
||||||
if (Glib::file_test (old_config_dir, Glib::FILE_TEST_IS_DIR)) {
|
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 (ui_handler (old_config_dir, current_config_dir, old_version)) {
|
||||||
if (r) {
|
copy_configuration_files (old_config_dir, current_config_dir, old_version);
|
||||||
if (r.get()) {
|
return 1;
|
||||||
copy_configuration_files (old_config_dir, current_config_dir, version);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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
|
// allow ardour the absolute maximum number of open files
|
||||||
lotsa_files_please ();
|
lotsa_files_please ();
|
||||||
|
|
||||||
maybe_copy_old_configuration_files ();
|
|
||||||
|
|
||||||
#ifdef HAVE_LRDF
|
#ifdef HAVE_LRDF
|
||||||
lrdf_init();
|
lrdf_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue