]> granicus.if.org Git - taglib/commitdiff
Parameter to disable duplication between ID3v1 and ID3v2 tags, #115.
authorUrs Fleisch <ufleisch@users.sourceforge.net>
Sat, 23 Mar 2013 12:56:31 +0000 (13:56 +0100)
committerUrs Fleisch <ufleisch@users.sourceforge.net>
Sat, 23 Mar 2013 12:56:31 +0000 (13:56 +0100)
taglib/mpeg/mpegfile.cpp
taglib/mpeg/mpegfile.h

index c73da41457c7b8bf53ce230235b548df62fb0148..51cb5784ec9a0f6a90170924dc854a0cfae5c6f6 100644 (file)
@@ -186,6 +186,11 @@ bool MPEG::File::save(int tags, bool stripOthers)
 }
 
 bool MPEG::File::save(int tags, bool stripOthers, int id3v2Version)
+{
+  return save(tags, stripOthers, id3v2Version, true);
+}
+
+bool MPEG::File::save(int tags, bool stripOthers, int id3v2Version, bool duplicateTags)
 {
   if(tags == NoTags && stripOthers)
     return strip(AllTags);
@@ -203,14 +208,19 @@ bool MPEG::File::save(int tags, bool stripOthers, int id3v2Version)
     return false;
   }
 
-  // Create the tags if we've been asked to.  Copy the values from the tag that
-  // does exist into the new tag, except if the existing tag is to be stripped.
+  // Create the tags if we've been asked to.
 
-  if((tags & ID3v2) && ID3v1Tag() && !(stripOthers && !(tags & ID3v1)))
-    Tag::duplicate(ID3v1Tag(), ID3v2Tag(true), false);
+  if (duplicateTags) {
 
-  if((tags & ID3v1) && d->tag[ID3v2Index] && !(stripOthers && !(tags & ID3v2)))
-    Tag::duplicate(ID3v2Tag(), ID3v1Tag(true), false);
+    // Copy the values from the tag that does exist into the new tag,
+    // except if the existing tag is to be stripped.
+
+    if((tags & ID3v2) && ID3v1Tag() && !(stripOthers && !(tags & ID3v1)))
+      Tag::duplicate(ID3v1Tag(), ID3v2Tag(true), false);
+
+    if((tags & ID3v1) && d->tag[ID3v2Index] && !(stripOthers && !(tags & ID3v2)))
+      Tag::duplicate(ID3v2Tag(), ID3v1Tag(true), false);
+  }
 
   bool success = true;
 
index 1d99898ce31631bf14c59698d203f42987623955..0c81788709f5402ae724a1ade0b5e47d7767ed17 100644 (file)
@@ -213,6 +213,24 @@ namespace TagLib {
       // BIC: combine with the above method
       bool save(int tags, bool stripOthers, int id3v2Version);
 
+      /*!
+       * 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.  This returns true if saving was successful.
+       *
+       * If \a stripOthers is true 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.
+       *
+       * The \a id3v2Version parameter specifies the version of the saved
+       * ID3v2 tag. It can be either 4 or 3.
+       *
+       * If \a duplicateTags is true and at least one tag -- ID3v1 or ID3v2 --
+       * exists this will duplicate its content into the other tag.
+       */
+      // BIC: combine with the above method
+      bool save(int tags, bool stripOthers, int id3v2Version, bool duplicateTags);
+
       /*!
        * Returns a pointer to the ID3v2 tag of the file.
        *