]> granicus.if.org Git - taglib/commitdiff
And now make it work for non-existing RIFF chunks.
authorScott Wheeler <wheeler@kde.org>
Fri, 16 May 2008 06:28:35 +0000 (06:28 +0000)
committerScott Wheeler <wheeler@kde.org>
Fri, 16 May 2008 06:28:35 +0000 (06:28 +0000)
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@808241 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

taglib/riff/rifffile.cpp

index 08227d877cb4a9168ef299697a4a13c95c6ebe4e..e7d557a9f58d061bb6bfcbfe0b72562c5c01ec4b 100644 (file)
@@ -138,7 +138,11 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data)
     }
   }
 
-  debug("Could not find chunk.");
+  // Couldn't find an existing chunk, so let's create a new one.  First update
+  // the global size:
+
+  insert(ByteVector::fromUInt(d->size + data.size() + 8, d->endianness == BigEndian), 4, 4);
+  writeChunk(name, data, d->chunkOffsets.back() + d->chunkSizes.back());
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -165,12 +169,10 @@ void RIFF::File::read()
     seek(chunkSize, Current);
   }
 }
-    
+
 void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data,
                             ulong offset, ulong replace)
 {
-  debug("Writting chunk at " + String::number(offset));
-
   ByteVector combined = name;
   combined.append(ByteVector::fromUInt(data.size(), d->endianness == BigEndian));
   combined.append(data);