snapshots now use the .template suffix instead of .xml

This commit is contained in:
Nikolaus Gullotta 2019-07-25 12:37:01 -05:00 committed by Nikolaus Gullotta
parent f31e21e047
commit d0e7768e30
No known key found for this signature in database
GPG key ID: 565F60578092AA31
2 changed files with 19 additions and 10 deletions

View file

@ -128,6 +128,7 @@ class LIBARDOUR_API MixerSnapshot
std::string label;
std::time_t timestamp;
std::string last_modified_with;
std::string suffix;
RecallFlags _flags;
std::vector<State> route_states;

View file

@ -54,6 +54,7 @@ MixerSnapshot::MixerSnapshot(Session* s)
, label("snapshot")
, timestamp(time(0))
, last_modified_with(string_compose("%1 %2", PROGRAM_NAME, revision))
, suffix (template_suffix)
, _flags(RecallFlags(127))
{
if(s) {
@ -67,29 +68,29 @@ MixerSnapshot::MixerSnapshot(Session* s, string file_path)
, label("snapshot")
, timestamp(time(0))
, last_modified_with(string_compose("%1 %2", PROGRAM_NAME, revision))
, suffix (template_suffix)
, _flags(RecallFlags(127))
{
if(s) {
_session = s;
}
//this is most likely a session dir
if(Glib::file_test(file_path.c_str(), Glib::FILE_TEST_IS_DIR)) {
load_from_session(file_path);
return;
}
string suffix = "." + get_suffix(file_path);
if(suffix == statefile_suffix) {
string file_suffix = "." + get_suffix(file_path);
//this is a session file
if(file_suffix == statefile_suffix) {
load_from_session(file_path);
return;
}
//this is a mixer template or snapshot
if(suffix == template_suffix) {
load_from_session(file_path);
return;
}
if(suffix == ".xml") {
load(file_path);
return;
}
@ -414,12 +415,18 @@ void MixerSnapshot::recall()
_session->commit_reversible_command();
}
void MixerSnapshot::write(const string path)
void MixerSnapshot::write(const string dir)
{
if(empty()) {
return;
}
if(!Glib::file_test(dir.c_str(), Glib::FILE_TEST_IS_DIR)) {
return;
}
string path = Glib::build_filename(dir, label + template_suffix);
XMLNode* node = new XMLNode("MixerSnapshot");
node->set_property(X_("flags"), _flags);
node->set_property(X_("favorite"), favorite);
@ -443,15 +450,16 @@ void MixerSnapshot::write(const string path)
XMLTree tree;
tree.set_root(node);
tree.write(path);
tree.write(path.c_str());
}
void MixerSnapshot::load(const string path)
{
clear();
if(!Glib::file_test(path.c_str(), Glib::FILE_TEST_EXISTS))
if(!Glib::file_test(path.c_str(), Glib::FILE_TEST_EXISTS)) {
return;
}
XMLTree tree;
tree.read(path);