+#else
+ /* this only affects stdio. 2048 is the maxium possible (512 the default).
+ *
+ * If we want more, we'll have to replaces the POSIX I/O interfaces with
+ * Win32 API calls (CreateFile, WriteFile, etc) which allows for 16K.
+ *
+ * see http://stackoverflow.com/questions/870173/is-there-a-limit-on-number-of-open-files-in-windows
+ * and http://bugs.mysql.com/bug.php?id=24509
+ */
+ int newmax = _setmaxstdio (2048);
+ if (newmax > 0) {
+ info << string_compose (_("Your system is configured to limit %1 to only %2 open files"), PROGRAM_NAME, newmax) << endmsg;
+ } else {
+ error << string_compose (_("Could not set system open files limit. Current limit is %1 open files"), _getmaxstdio()) << endmsg;
+ }
+#endif
+}
+
+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, X_("recent"));
+ new_name = Glib::build_filename (new_dir, X_("recent"));
+
+ copy_file (old_name, new_name);
+
+ old_name = Glib::build_filename (old_dir, X_("sfdb"));
+ new_name = Glib::build_filename (new_dir, X_("sfdb"));
+
+ copy_file (old_name, new_name);
+
+ /* can only copy ardour.rc/config - UI config is not compatible */
+
+ /* users who have been using git/nightlies since the last
+ * release of 3.5 will have $CONFIG/config rather than
+ * $CONFIG/ardour.rc. Pick up the newer "old" config file,
+ * to avoid confusion.
+ */
+
+ string old_name = Glib::build_filename (old_dir, X_("config"));
+
+ if (!Glib::file_test (old_name, Glib::FILE_TEST_EXISTS)) {
+ 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, X_("templates"));
+ new_name = Glib::build_filename (new_dir, X_("templates"));
+
+ copy_recurse (old_name, new_name);
+
+ 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, 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, X_("plugin_statuses"));
+ new_name = Glib::build_filename (new_dir, X_("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, 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));
+ copy_file (from, to);
+ }
+ }
+
+ return 0;
+}
+
+void
+ARDOUR::check_for_old_configuration_files ()
+{
+ int current_version = atoi (X_(PROGRAM_VERSION));
+
+ if (current_version <= 1) {
+ return;
+ }
+
+ int old_version = current_version - 1;
+
+ 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)) {
+ have_old_configuration_files = true;
+ }
+ }
+}
+
+int
+ARDOUR::handle_old_configuration_files (boost::function<bool (std::string const&, std::string const&, int)> ui_handler)
+{
+ if (have_old_configuration_files) {
+ int current_version = atoi (X_(PROGRAM_VERSION));
+ assert (current_version > 1); // established in check_for_old_configuration_files ()
+ int old_version = current_version - 1;
+ string old_config_dir = user_config_directory (old_version);
+ string current_config_dir = user_config_directory (current_version);
+
+ 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;