prevent ardour from ever, EVER, EVAH removing an existing source file

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@8841 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-02-14 15:58:17 +00:00
parent c6af72af12
commit e51541e5f0
3 changed files with 25 additions and 3 deletions

View file

@ -178,6 +178,7 @@ class AudioFileSource : public AudioSource {
Glib::ustring broken_peak_path (Glib::ustring audio_path);
void fix_writable_flags ();
void prevent_deletion ();
};
} // namespace ARDOUR

View file

@ -96,6 +96,7 @@ AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags)
throw failed_constructor ();
}
prevent_deletion ();
fix_writable_flags ();
}
@ -110,6 +111,7 @@ AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags, SampleFo
throw failed_constructor ();
}
prevent_deletion ();
fix_writable_flags ();
}
@ -129,6 +131,7 @@ AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exi
throw failed_constructor ();
}
prevent_deletion ();
fix_writable_flags ();
}
@ -140,9 +143,26 @@ AudioFileSource::~AudioFileSource ()
}
}
void
AudioFileSource::prevent_deletion ()
{
/* if this file already exists, it cannot be removed, ever
*/
if (Glib::file_test (_path, Glib::FILE_TEST_EXISTS)) {
if (!(_flags & Destructive)) {
mark_immutable ();
} else {
_flags = Flag (_flags & ~(Removable|RemovableIfEmpty|RemoveAtDestroy));
}
}
}
void
AudioFileSource::fix_writable_flags ()
{
/* if the session is not writable, neither is this file
*/
if (!_session.writable()) {
_flags = Flag (_flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename));
}
@ -354,6 +374,7 @@ AudioFileSource::mark_for_remove ()
}
_flags = Flag (_flags | Removable | RemoveAtDestroy);
}
void
@ -466,6 +487,7 @@ AudioFileSource::move_to_trash (const ustring& trash_dir_name)
_flags = Flag (_flags & ~(RemoveAtDestroy|Removable|RemovableIfEmpty));
return 0;
}
@ -775,7 +797,6 @@ AudioFileSource::mark_immutable ()
}
}
Sample*
AudioFileSource::get_interleave_buffer (nframes_t size)
{

View file

@ -633,7 +633,7 @@ bool
SndFileSource::set_destructive (bool yn)
{
if (yn) {
_flags = Flag (_flags | Destructive);
_flags = Flag (_flags | Writable | Destructive);
if (!xfade_buf) {
xfade_buf = new Sample[xfade_frames];
}
@ -644,7 +644,7 @@ SndFileSource::set_destructive (bool yn)
timeline_position = 0;
/* leave xfade buf alone in case we need it again later */
}
return true;
}