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
This commit is contained in:
Scott Wheeler 2008-05-16 06:28:35 +00:00
parent 1d1fab1122
commit 123aa8a775

View 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);