From c52f7957a9b350dbb0d290a39acd33eb4472a218 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 10 Apr 2014 08:58:04 -0400 Subject: 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. --- libs/ardour/file_source.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'libs/ardour/file_source.cc') diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc index 288a4b7034..2b8a65ab92 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 { @@ -527,10 +533,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; -- cgit v1.2.3