summaryrefslogtreecommitdiff
path: root/libs/ardour/file_source.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-04-10 08:58:04 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-04-14 13:04:14 -0400
commit384c0a9facf1bfecc783ac048dbb0bae4ad901fd (patch)
tree6d7aa5fc5396d210612c9f692269cdf0109f096c /libs/ardour/file_source.cc
parent2b3cb052caa3426866b67ab14afac84a3dc764a9 (diff)
redesign technique for naming/creating regions for MIDI clone (or other non-capture driven MIDI region creation operations).
See comments in Session::new_midi_source_name() for details.
Diffstat (limited to 'libs/ardour/file_source.cc')
-rw-r--r--libs/ardour/file_source.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc
index c6f3a9cd5d..de7365962f 100644
--- a/libs/ardour/file_source.cc
+++ b/libs/ardour/file_source.cc
@@ -81,6 +81,10 @@ FileSource::FileSource (Session& session, const XMLNode& node, bool /*must_exist
prevent_deletion ();
}
+FileSource::~FileSource()
+{
+}
+
void
FileSource::prevent_deletion ()
{
@@ -88,6 +92,8 @@ FileSource::prevent_deletion ()
*/
if (Glib::file_test (_path, Glib::FILE_TEST_EXISTS)) {
+ cerr << " ... " << _path << " already exists, marking immutable\n";
+
if (!(_flags & Destructive)) {
mark_immutable ();
} else {
@@ -536,10 +542,13 @@ FileSource::set_source_name (const string& newname, bool destructive)
return -1;
}
- if (::rename (oldpath.c_str(), newpath.c_str()) != 0) {
- error << string_compose (_("cannot rename file %1 to %2 (%3)"), oldpath, newpath, strerror(errno)) << endmsg;
- return -1;
- }
+ if (Glib::file_test (oldpath.c_str(), Glib::FILE_TEST_EXISTS)) {
+ /* rename only needed if file exists on disk */
+ if (::rename (oldpath.c_str(), newpath.c_str()) != 0) {
+ error << string_compose (_("cannot rename file %1 to %2 (%3)"), oldpath, newpath, strerror(errno)) << endmsg;
+ return -1;
+ }
+ }
_name = Glib::path_get_basename (newpath);
_path = newpath;