Use functions from pbd/filesystem.h in Session::remove_state for portability

Add ARDOUR::backup_suffix to ardour/filename_extensions.h/cc


git-svn-id: svn://localhost/ardour2/trunk@2374 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Tim Mayberry
2007-09-04 04:48:09 +00:00
parent 911e30a73a
commit b49e50afac
3 changed files with 11 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ extern const char* const template_suffix;
extern const char* const statefile_suffix;
extern const char* const pending_suffix;
extern const char* const peakfile_suffix;
extern const char* const backup_suffix;
}

View File

@@ -8,5 +8,6 @@ const char* const template_suffix = X_(".template");
const char* const statefile_suffix = X_(".ardour");
const char* const pending_suffix = X_(".pending");
const char* const peakfile_suffix = X_(".peak");
const char* const backup_suffix = X_(".bak");
}

View File

@@ -538,17 +538,20 @@ Session::remove_state (string snapshot_name)
/* refuse to remove the current snapshot or the "main" one */
return;
}
const string xml_path = _path + snapshot_name + statefile_suffix;
sys::path xml_path(_session_dir->root_path());
xml_path /= snapshot_name + statefile_suffix;
sys::path backup_path(xml_path.to_string() + backup_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);
if (sys::exists (xml_path)) {
copy_file (xml_path.to_string(), backup_path.to_string());
}
/* and delete it */
unlink (xml_path.c_str());
sys::remove (xml_path);
}
int