return d->tag.access<RIFF::Info::Tag>(InfoIndex, false);
}
+void RIFF::WAV::File::strip(TagTypes tags)
+{
+ removeTagChunks(tags);
+
+ if(tags & ID3v2)
+ d->tag.set(ID3v2Index, new ID3v2::Tag());
+
+ if(tags & Info)
+ d->tag.set(InfoIndex, new RIFF::Info::Tag());
+}
+
PropertyMap RIFF::WAV::File::properties() const
{
return tag()->properties();
if(stripOthers)
strip(static_cast<TagTypes>(AllTags & ~tags));
- const ID3v2::Tag *id3v2tag = d->tag.access<ID3v2::Tag>(ID3v2Index, false);
if(tags & ID3v2) {
- if(d->hasID3v2) {
- removeChunk(d->tagChunkID);
- d->hasID3v2 = false;
- }
+ removeTagChunks(ID3v2);
- if(!id3v2tag->isEmpty()) {
- setChunkData(d->tagChunkID, id3v2tag->render(id3v2Version));
+ if(ID3v2Tag() && !ID3v2Tag()->isEmpty()) {
+ setChunkData(d->tagChunkID, ID3v2Tag()->render(id3v2Version));
d->hasID3v2 = true;
}
}
- const Info::Tag *infotag = d->tag.access<Info::Tag>(InfoIndex, false);
if(tags & Info) {
- if(d->hasInfo) {
- removeChunk(findInfoTagChunk());
- d->hasInfo = false;
- }
+ removeTagChunks(Info);
- if(!infotag->isEmpty()) {
- setChunkData("LIST", infotag->render(), true);
+ if(InfoTag() && !InfoTag()->isEmpty()) {
+ setChunkData("LIST", InfoTag()->render(), true);
d->hasInfo = true;
}
}
d->properties = new Properties(this, Properties::Average);
}
-void RIFF::WAV::File::strip(TagTypes tags)
+void RIFF::WAV::File::removeTagChunks(TagTypes tags)
{
- if(tags & ID3v2) {
- removeChunk(d->tagChunkID);
+ if((tags & ID3v2) && d->hasID3v2) {
+ removeChunk("ID3 ");
+ removeChunk("id3 ");
+
d->hasID3v2 = false;
}
- if(tags & Info){
- TagLib::uint chunkId = findInfoTagChunk();
- if(chunkId != TagLib::uint(-1)) {
- removeChunk(chunkId);
- d->hasInfo = false;
+ if((tags & Info) && d->hasInfo) {
+ for(int i = static_cast<int>(chunkCount()) - 1; i >= 0; --i) {
+ if(chunkName(i) == "LIST" && chunkData(i).startsWith("INFO"))
+ removeChunk(i);
}
- }
-}
-TagLib::uint RIFF::WAV::File::findInfoTagChunk()
-{
- for(uint i = 0; i < chunkCount(); ++i) {
- if(chunkName(i) == "LIST" && chunkData(i).startsWith("INFO")) {
- return i;
- }
+ d->hasInfo = false;
}
-
- return TagLib::uint(-1);
}
*/
Info::Tag *InfoTag() const;
+ /*!
+ * This will strip the tags that match the OR-ed together TagTypes from the
+ * file. By default it strips all tags. It returns true if the tags are
+ * successfully stripped.
+ *
+ * \note This will update the file immediately.
+ */
+ void strip(TagTypes tags = AllTags);
+
/*!
* Implements the unified property interface -- export function.
* This method forwards to ID3v2::Tag::properties().
File &operator=(const File &);
void read(bool readProperties);
-
- void strip(TagTypes tags);
-
- /*!
- * Returns the index of the chunk that its name is "LIST" and list type is "INFO".
- */
- uint findInfoTagChunk();
+ void removeTagChunks(TagTypes tags);
friend class Properties;