Skip to content

Commit

Permalink
Add some debug messages to RIFF::File, just in case.
Browse files Browse the repository at this point in the history
  • Loading branch information
TsudaKageyu committed Feb 22, 2016
1 parent e8ef0e0 commit 2aea23a
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions taglib/riff/rifffile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,38 +100,62 @@ unsigned int RIFF::File::chunkCount() const

unsigned int RIFF::File::chunkDataSize(unsigned int i) const
{
if(i >= d->chunks.size()) {
debug("RIFF::File::chunkPadding() - Index out of range. Returning 0.");
return 0;
}

return d->chunks[i].size;
}

unsigned int RIFF::File::chunkOffset(unsigned int i) const
{
if(i >= d->chunks.size()) {
debug("RIFF::File::chunkPadding() - Index out of range. Returning 0.");
return 0;
}

return d->chunks[i].offset;
}

unsigned int RIFF::File::chunkPadding(unsigned int i) const
{
if(i >= d->chunks.size()) {
debug("RIFF::File::chunkPadding() - Index out of range. Returning 0.");
return 0;
}

return d->chunks[i].padding;
}

ByteVector RIFF::File::chunkName(unsigned int i) const
{
if(i >= chunkCount())
if(i >= d->chunks.size()) {
debug("RIFF::File::chunkName() - Index out of range. Returning an empty vector.");
return ByteVector();
}

return d->chunks[i].name;
}

ByteVector RIFF::File::chunkData(unsigned int i)
{
if(i >= chunkCount())
if(i >= d->chunks.size()) {
debug("RIFF::File::chunkData() - Index out of range. Returning an empty vector.");
return ByteVector();
}

seek(d->chunks[i].offset);
return readBlock(d->chunks[i].size);
}

void RIFF::File::setChunkData(unsigned int i, const ByteVector &data)
{
if(i >= d->chunks.size()) {
debug("RIFF::File::setChunkData() - Index out of range.");
return;
}

// Now update the specific chunk

std::vector<Chunk>::iterator it = d->chunks.begin();
Expand Down Expand Up @@ -223,6 +247,11 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo

void RIFF::File::removeChunk(unsigned int i)
{
if(i >= d->chunks.size()) {
debug("RIFF::File::removeChunk() - Index out of range.");
return;
}

std::vector<Chunk>::iterator it = d->chunks.begin();
std::advance(it, i);

Expand Down

0 comments on commit 2aea23a

Please sign in to comment.