throw failed_constructor ();
}
+ fix_writable_flags ();
}
AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags, SampleFormat samp_format, HeaderFormat hdr_format)
if (init (path, false)) {
throw failed_constructor ();
}
+
+ fix_writable_flags ();
}
AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist)
if (init (foo, must_exist)) {
throw failed_constructor ();
}
+
+ fix_writable_flags ();
}
AudioFileSource::~AudioFileSource ()
}
}
+void
+AudioFileSource::fix_writable_flags ()
+{
+ if (!_session.writable()) {
+ _flags = Flag (_flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename));
+ }
+}
+
bool
AudioFileSource::determine_embeddedness (ustring path)
{
return (_flags & Removable) && ((_flags & RemoveAtDestroy) || ((_flags & RemovableIfEmpty) && length() == 0));
}
+bool
+AudioFileSource::writable() const
+{
+ return (_flags & Writable);
+}
+
int
AudioFileSource::init (ustring pathstr, bool must_exist)
{
timeline_position = 0;
_peaks_built = false;
- if (!find (pathstr, must_exist, is_embedded(), file_is_new, _channel, _path, _name)) {
+ /* is_embedded() can't work yet, because our _path is not set */
+
+ bool embedded = determine_embeddedness (pathstr);
+
+ if (!find (pathstr, must_exist, embedded, file_is_new, _channel, _path, _name)) {
throw non_existent_source ();
}
}
+ fix_writable_flags ();
+
if ((prop = node.property (X_("channel"))) != 0) {
_channel = atoi (prop->value());
} else {
// This operation is not allowed for sources for destructive tracks or embedded files.
// Fortunately mark_for_remove() is never called for embedded files. This function
// must be fixed if that ever happens.
- if (_flags & Destructive) {
+ if (!_session.writable() || (_flags & Destructive)) {
return;
}
if (embedded) {
name = pathstr;
} else {
- name = pathstr.substr (pathstr.find_last_of ('/') + 1);
+ name = Glib::path_get_basename (pathstr);
}
if (!Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
} else {
_flags = Flag (_flags & ~RemovableIfEmpty);
}
+
+ fix_writable_flags ();
}
int
".maud", ".MAUD",
".vwe", ".VWE",
".paf",
-#ifdef HAVE_FLAC
".flac", ".FLAC",
-#endif // HAVE_FLAC
+ ".ogg", ".OGG",
#ifdef HAVE_COREAUDIO
".mp3", ".MP3",
".aac", ".AAC",