return d->properties;
}
-void MPEG::File::save()
+bool MPEG::File::save()
{
- save(ID3v1 | ID3v2);
+ return save(ID3v1 | ID3v2);
}
-void MPEG::File::save(int tags)
+bool MPEG::File::save(int tags)
{
- if(tags == NoTags) {
- strip(AllTags);
- return;
- }
+ if(tags == NoTags)
+ return strip(AllTags);
if(!d->ID3v2Tag && !d->ID3v1Tag) {
if(d->hasID3v1 || d->hasID3v2)
- strip(AllTags);
+ return strip(AllTags);
- return;
+ return true;
}
if(readOnly()) {
debug("MPEG::File::save() -- File is read only.");
- return;
+ return false;
}
// Create the tags if we've been asked to. Copy the values from the tag that
if(tags & ID3v1 && d->ID3v2Tag)
Tag::duplicate(d->ID3v2Tag, ID3v1Tag(true), false);
+ bool success = true;
if(ID3v2 & tags) {
insert(d->ID3v2Tag->render(), d->ID3v2Location, d->ID3v2OriginalSize);
}
else
- strip(ID3v2);
+ success = strip(ID3v2) && success;
}
else if(d->hasID3v2)
- strip(ID3v2);
+ success = strip(ID3v2) && success;
if(ID3v1 & tags) {
if(d->ID3v1Tag && !d->ID3v1Tag->isEmpty()) {
writeBlock(d->ID3v1Tag->render());
}
else
- strip(ID3v1);
+ success = strip(ID3v1) && success;
}
else if(d->hasID3v1)
- strip(ID3v1);
+ success = strip(ID3v1) && success;
+
+ return success;
}
ID3v2::Tag *MPEG::File::ID3v2Tag(bool create)
return d->ID3v1Tag;
}
-void MPEG::File::strip(int tags)
+bool MPEG::File::strip(int tags)
{
if(readOnly()) {
debug("MPEG::File::strip() - Cannot strip tags from a read only file.");
- return;
+ return false;
}
if(tags & ID3v2 && d->hasID3v2)
d->ID3v1Location = -1;
d->hasID3v1 = false;
}
+
+ return true;
}
void MPEG::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory)
/*!
* Save the file. If at least one tag -- ID3v1 or ID3v2 -- exists this
- * will duplicate its content into the other tag.
+ * will duplicate its content into the other tag. This returns true
+ * if saving was successful.
*
* If neither exists or if both tags are empty, this will strip the tags
* from the file.
*
* \see save(int tags)
*/
- virtual void save();
+ virtual bool save();
/*!
* Save the file. This will attempt to save all of the tag types that are
* specified by OR-ing together TagTypes values. The save() method above
- * uses AllTags.
+ * uses AllTags. This returns true if saving was successful.
*
* This strips all tags not included in the mask, but does not modify them
* in memory, so later calls to save() which make use of these tags will
* remain valid. This also strips empty tags.
*/
- void save(int tags);
+ bool save(int tags);
/*!
* Returns a pointer to the ID3v2 tag of the file.
* This will strip the tags that match the OR-ed together TagTypes from the
* file. By default it strips all tags.
*/
- void strip(int tags = AllTags);
+ bool strip(int tags = AllTags);
/*!
* Set the ID3v2::FrameFactory to something other than the default.
return d->lastPageHeader->isValid() ? d->lastPageHeader : 0;
}
-void Ogg::File::save()
+bool Ogg::File::save()
{
+ if(readOnly()) {
+ debug("Ogg::File::save() - Cannot save to a read only file.");
+ return false;
+ }
+
List<int> pageGroup;
for(List<int>::ConstIterator it = d->dirtyPages.begin(); it != d->dirtyPages.end(); ++it) {
writePageGroup(pageGroup);
d->dirtyPages.clear();
d->dirtyPackets.clear();
+
+ return true;
}
////////////////////////////////////////////////////////////////////////////////
*/
const PageHeader *lastPageHeader();
- virtual void save();
+ virtual bool save();
protected:
/*!
return d->properties;
}
-void Vorbis::File::save()
+bool Vorbis::File::save()
{
ByteVector v(vorbisCommentHeaderID);
setPacket(1, v);
- Ogg::File::save();
+ return Ogg::File::save();
}
////////////////////////////////////////////////////////////////////////////////
*/
virtual Properties *audioProperties() const;
- virtual void save();
+ virtual bool save();
private:
File(const File &);
/*!
* Save the file and its associated tags. This should be reimplemented in
- * the concrete subclasses.
+ * the concrete subclasses. Returns true if the save succeeds.
*/
- virtual void save() = 0;
+ virtual bool save() = 0;
/*!
* Reads a block of size \a length at the current get pointer.