summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-04-06 12:57:41 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-04-06 12:57:41 +0000
commitf388715a5937bdb30b221d31606ffa0d1b58c8f3 (patch)
tree1bcbf42e2444efc8872ee2171e3be3b0826f2300 /libs
parent0eafb1f3005d0ddf9f8ce8c6bde30f0ac641aa61 (diff)
don't let auditioning make transport buttons inaccessible; delete/rename snapshots (from carl & puddingpimp)
git-svn-id: svn://localhost/ardour2/trunk@1673 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/session.h2
-rw-r--r--libs/ardour/session_state.cc45
2 files changed, 47 insertions, 0 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 6324dd5278..a14daa4485 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -411,6 +411,8 @@ class Session : public PBD::StatefulDestructible
int save_template (string template_name);
int save_history (string snapshot_name = "");
int restore_history (string snapshot_name);
+ void remove_state (string snapshot_name);
+ void rename_state (string old_name, string new_name);
static int rename_template (string old_name, string new_name);
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index dfa95161a9..70d9cd12d7 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -593,6 +593,48 @@ Session::remove_pending_capture_state ()
unlink (xml_path.c_str());
}
+/** Rename a state file.
+ * @param snapshot_name Snapshot name.
+ */
+void
+Session::rename_state (string old_name, string new_name)
+{
+ if (old_name == _current_snapshot_name || old_name == _name) {
+ /* refuse to rename the current snapshot or the "main" one */
+ return;
+ }
+
+ const string old_xml_path = _path + old_name + _statefile_suffix;
+ const string new_xml_path = _path + new_name + _statefile_suffix;
+
+ if (rename (old_xml_path.c_str(), new_xml_path.c_str()) != 0) {
+ error << string_compose(_("could not rename snapshot %1 to %2"), old_name, new_name) << endmsg;
+ }
+}
+
+/** Remove a state file.
+ * @param snapshot_name Snapshot name.
+ */
+void
+Session::remove_state (string snapshot_name)
+{
+ if (snapshot_name == _current_snapshot_name || snapshot_name == _name) {
+ /* refuse to remove the current snapshot or the "main" one */
+ return;
+ }
+
+ const string xml_path = _path + snapshot_name + _statefile_suffix;
+
+ /* make a backup copy of the state file */
+ const string bak_path = xml_path + ".bak";
+ if (g_file_test (xml_path.c_str(), G_FILE_TEST_EXISTS)) {
+ copy_file (xml_path, bak_path);
+ }
+
+ /* and delete it */
+ unlink (xml_path.c_str());
+}
+
int
Session::save_state (string snapshot_name, bool pending)
{
@@ -618,10 +660,12 @@ Session::save_state (string snapshot_name, bool pending)
if (!pending) {
+ /* proper save: use _statefile_suffix (.ardour in English) */
xml_path = _path;
xml_path += snapshot_name;
xml_path += _statefile_suffix;
+ /* make a backup copy of the old file */
bak_path = xml_path;
bak_path += ".bak";
@@ -631,6 +675,7 @@ Session::save_state (string snapshot_name, bool pending)
} else {
+ /* pending save: use _pending_suffix (.pending in English) */
xml_path = _path;
xml_path += snapshot_name;
xml_path += _pending_suffix;