From 123aa8a775e769d92d023d001f7e774b1050c213 Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Fri, 16 May 2008 06:28:35 +0000 Subject: [PATCH] And now make it work for non-existing RIFF chunks. git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@808241 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- taglib/riff/rifffile.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index 08227d87..e7d557a9 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -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);