Use g_rename instead of PBD::sys::rename in Session::save_history
authorTim Mayberry <mojofunk@gmail.com>
Sat, 23 Jun 2012 05:08:44 +0000 (05:08 +0000)
committerTim Mayberry <mojofunk@gmail.com>
Sat, 23 Jun 2012 05:08:44 +0000 (05:08 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12875 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/session_state.cc

index b2c34e08b846dfbc91526bd7566416b8a1b09432..5f7e1c239312d03783103f325a18d2ba480d473e 100644 (file)
@@ -3248,16 +3248,11 @@ Session::save_history (string snapshot_name)
 
        const string history_filename = legalize_for_path (snapshot_name) + history_suffix;
        const string backup_filename = history_filename + backup_suffix;
-       const sys::path xml_path(Glib::build_filename (_session_dir->root_path(), history_filename));
-       const sys::path backup_path(Glib::build_filename (_session_dir->root_path(), backup_filename));
+       const std::string xml_path(Glib::build_filename (_session_dir->root_path(), history_filename));
+       const std::string backup_path(Glib::build_filename (_session_dir->root_path(), backup_filename));
 
        if (sys::exists (xml_path)) {
-               try
-               {
-                       sys::rename (xml_path, backup_path);
-               }
-               catch (const sys::filesystem_error& err)
-               {
+               if (::g_rename (xml_path.c_str(), backup_path.c_str()) != 0) {
                        error << _("could not backup old history file, current history not saved") << endmsg;
                        return -1;
                }
@@ -3269,22 +3264,17 @@ Session::save_history (string snapshot_name)
 
        tree.set_root (&_history.get_state (Config->get_saved_history_depth()));
 
-       if (!tree.write (xml_path.to_string()))
+       if (!tree.write (xml_path))
        {
-               error << string_compose (_("history could not be saved to %1"), xml_path.to_string()) << endmsg;
+               error << string_compose (_("history could not be saved to %1"), xml_path) << endmsg;
 
-               try
-               {
-                       if (g_remove (xml_path.to_string().c_str()) != 0) {
-                               error << string_compose(_("Could not remove history file at path \"%1\" (%2)"),
-                                               xml_path.to_string(), g_strerror (errno)) << endmsg;
-                       }
-                       sys::rename (backup_path, xml_path);
+               if (g_remove (xml_path.c_str()) != 0) {
+                       error << string_compose(_("Could not remove history file at path \"%1\" (%2)"),
+                                       xml_path, g_strerror (errno)) << endmsg;
                }
-               catch (const sys::filesystem_error& err)
-               {
+               if (::g_rename (backup_path.c_str(), xml_path.c_str()) != 0) {
                        error << string_compose (_("could not restore history file from backup %1 (%2)"),
-                                       backup_path.to_string(), err.what()) << endmsg;
+                                       backup_path, g_strerror (errno)) << endmsg;
                }
 
                return -1;