diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-04-10 08:58:04 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-04-10 08:58:04 -0400 |
commit | c52f7957a9b350dbb0d290a39acd33eb4472a218 (patch) | |
tree | 0998cb649e23ca8b98a782c5a34d7f9932ab2076 /libs/ardour/file_source.cc | |
parent | 0802cbf30cc576e68df90b793b74f8691a7a4311 (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.cc | 17 |
1 files changed, 13 insertions, 4 deletions
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; |