Use g_strerror() instead of ::strerror() in Session::cleanup_sources
[ardour.git] / libs / ardour / session_state.cc
index 76cf2d375599dfda5a8b2bddcfe9ab6a155b5370..5729c889bd8380bfc88cd506284b03eadaa87a79 100644 (file)
@@ -1000,6 +1000,20 @@ Session::load_state (string snapshot_name)
                                return -1;
                        }
                }
+       } else {
+               XMLNode* child;
+               if ((child = find_named_node (root, "ProgramVersion")) != 0) {
+                       if ((prop = child->property ("modified-with")) != 0) {
+                               std::string modified_with = prop->value ();
+
+                               const double modified_with_version = atof (modified_with.substr ( modified_with.find(" ", 0) + 1, string::npos).c_str());
+                               const int modified_with_revision = atoi (modified_with.substr (modified_with.find("-", 0) + 1, string::npos).c_str());
+
+                               if (modified_with_version <= 5.3 && !(modified_with_version == 5.3 && modified_with_revision > 42)) {
+                                       _midi_regions_use_bbt_beats = true;
+                               }
+                       }
+               }
        }
 
        save_snapshot_name (snapshot_name);
@@ -3290,36 +3304,37 @@ Session::cleanup_sources (CleanupReport& rep)
 
                }
 
-               g_stat ((*x).c_str(), &statbuf);
+               if (0 == g_stat ((*x).c_str(), &statbuf)) {
 
-               if (::rename ((*x).c_str(), newpath.c_str()) != 0) {
-                       error << string_compose (_("cannot rename unused file source from %1 to %2 (%3)"), (*x), newpath, strerror (errno)) << endmsg;
-                       continue;
-               }
+                       if (::g_rename ((*x).c_str(), newpath.c_str()) != 0) {
+                               error << string_compose (_("cannot rename unused file source from %1 to %2 (%3)"), (*x), newpath, g_strerror (errno)) << endmsg;
+                               continue;
+                       }
 
-               /* see if there an easy to find peakfile for this file, and remove it.
-                */
+                       /* see if there an easy to find peakfile for this file, and remove it.
+                        */
 
-                string base = Glib::path_get_basename (*x);
-                base += "%A"; /* this is what we add for the channel suffix of all native files,
-                                 or for the first channel of embedded files. it will miss
-                                 some peakfiles for other channels
-                              */
-               string peakpath = construct_peak_filepath (base);
-
-               if (Glib::file_test (peakpath.c_str(), Glib::FILE_TEST_EXISTS)) {
-                       if (::g_unlink (peakpath.c_str()) != 0) {
-                               error << string_compose (_("cannot remove peakfile %1 for %2 (%3)"),
-                                                         peakpath, _path, strerror (errno))
-                                     << endmsg;
-                               /* try to back out */
-                               ::rename (newpath.c_str(), _path.c_str());
-                               goto out;
+                                       string base = Glib::path_get_basename (*x);
+                                       base += "%A"; /* this is what we add for the channel suffix of all native files,
+                                                                        or for the first channel of embedded files. it will miss
+                                                                        some peakfiles for other channels
+                                                                 */
+                       string peakpath = construct_peak_filepath (base);
+
+                       if (Glib::file_test (peakpath.c_str(), Glib::FILE_TEST_EXISTS)) {
+                               if (::g_unlink (peakpath.c_str()) != 0) {
+                                       error << string_compose (_("cannot remove peakfile %1 for %2 (%3)"),
+                                                                                                                        peakpath, _path, g_strerror (errno))
+                                                 << endmsg;
+                                       /* try to back out */
+                                       ::g_rename (newpath.c_str(), _path.c_str());
+                                       goto out;
+                               }
                        }
-               }
 
-               rep.paths.push_back (*x);
-               rep.space += statbuf.st_size;
+                       rep.paths.push_back (*x);
+                       rep.space += statbuf.st_size;
+               }
        }
 
        /* dump the history list */
@@ -4916,3 +4931,23 @@ Session::save_as (SaveAs& saveas)
 
        return 0;
 }
+
+void
+Session::undo (uint32_t n)
+{
+       if (actively_recording()) {
+               return;
+       }
+
+       _history.undo (n);
+}
+
+void
+Session::redo (uint32_t n)
+{
+       if (actively_recording()) {
+               return;
+       }
+
+       _history.redo (n);
+}