[ardour-dev] fix for the absolute automation paths for redirects
Jeremy Hall
jhall at maoz.com
Wed Jun 23 07:22:28 PDT 2004
Hello,
Attached is a diff that fixes absolute pathnames in automation state for
redirects. If the problem exists for other automation types, I will fix
them as well. This is simply a code review.
_J
-------------- next part --------------
Index: redirect.cc
===================================================================
RCS file: /home/las/cvsroot/ardour/ardour/libs/ardour/redirect.cc,v
retrieving revision 1.36
diff -u -r1.36 redirect.cc
--- redirect.cc 20 May 2004 03:31:26 -0000 1.36
+++ redirect.cc 23 Jun 2004 14:15:17 -0000
@@ -104,10 +104,20 @@
int
Redirect::load_automation (string path)
{
- ifstream in (path.c_str());
+ string fullpath;
+
+ if (path[0] == '/') { // legacy
+ fullpath = path;
+ } else {
+ fullpath = _session.automation_dir();
+ fullpath += _session.snap_name();
+ fullpath += '-';
+ fullpath += path;
+ }
+ ifstream in (fullpath.c_str());
if (!in) {
- warning << compose(_("%1: cannot open %2 to load automation data (%3)"), _name, path, strerror (errno)) << endmsg;
+ warning << compose(_("%1: cannot open %2 to load automation data (%3)"), _name, fullpath, strerror (errno)) << endmsg;
return 1;
}
@@ -136,7 +146,7 @@
return 0;
bad:
- error << compose(_("%1: cannot load automation data from %2"), _name, path) << endmsg;
+ error << compose(_("%1: cannot load automation data from %2"), _name, fullpath) << endmsg;
parameter_automation.clear ();
return -1;
}
@@ -145,12 +155,18 @@
Redirect::save_automation (string path)
{
LockMonitor lm (_automation_lock, __LINE__, __FILE__);
+ string fullpath;
if (parameter_automation.empty()) {
return 1;
}
- ofstream out (path.c_str());
+ fullpath = _session.automation_dir();
+ fullpath += _session.snap_name();
+ fullpath += '-';
+ fullpath += path;
+
+ ofstream out (fullpath.c_str());
if (!out) {
error << compose(_("%1: cannot open %2 to store automation data (%3)"), _name, path, strerror (errno)) << endmsg;
@@ -171,15 +187,15 @@
}
if (i != (*li).second->end()) {
- unlink (path.c_str());
- error << compose(_("%1: could not save automation state to %2"), _name, path) << endmsg;
+ unlink (fullpath.c_str());
+ error << compose(_("%1: could not save automation state to %2"), _name, fullpath) << endmsg;
return -1;
}
}
if (li != parameter_automation.end()) {
- unlink (path.c_str());
- error << compose(_("%1: could not save automation state to %2"), _name, path) << endmsg;
+ unlink (fullpath.c_str());
+ error << compose(_("%1: could not save automation state to %2"), _name, fullpath) << endmsg;
return -1;
}
@@ -204,10 +220,8 @@
string path;
string legal_name;
- path = _session.path();
- path += "/automation/";
snprintf (buf, sizeof(buf), "%Lu", id());
- path += buf;
+ path = buf;
path += ".auto";
/* XXX we didn't ask for a state save, we asked for the current state.
More information about the Ardour-Dev
mailing list