mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Removed some redundant code about checking chunk names of RIFF files
This commit is contained in:
parent
60590c0a1a
commit
5c9360afa2
@ -69,6 +69,20 @@ RIFF::File::~File()
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool RIFF::File::isValidChunkName(const ByteVector &name) // static
|
||||
{
|
||||
if(name.size() != 4)
|
||||
return false;
|
||||
|
||||
for(ByteVector::ConstIterator it = name.begin(); it != name.end(); ++it) {
|
||||
const uchar c = static_cast<uchar>(*it);
|
||||
if(c < 32 || 127 < c)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// protected members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -253,22 +267,6 @@ void RIFF::File::removeChunk(const ByteVector &name)
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace
|
||||
{
|
||||
bool isValidChunkID(const ByteVector &name)
|
||||
{
|
||||
if(name.size() != 4) {
|
||||
return false;
|
||||
}
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(name[i] < 32 || name[i] > 127) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void RIFF::File::read()
|
||||
{
|
||||
d->type = readBlock(4);
|
||||
@ -289,7 +287,7 @@ void RIFF::File::read()
|
||||
else
|
||||
chunkSize = readBlock(4).toUInt32LE(0);
|
||||
|
||||
if(!isValidChunkID(chunkName)) {
|
||||
if(!isValidChunkName(chunkName)) {
|
||||
debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid ID");
|
||||
setValid(false);
|
||||
break;
|
||||
|
@ -51,6 +51,11 @@ namespace TagLib {
|
||||
*/
|
||||
virtual ~File();
|
||||
|
||||
/*!
|
||||
* Returns whether or not \a name is valid as a chunk name.
|
||||
*/
|
||||
static bool isValidChunkName(const ByteVector &name);
|
||||
|
||||
protected:
|
||||
|
||||
File(FileName file, ByteOrder endianness);
|
||||
|
@ -26,27 +26,12 @@
|
||||
#include <tdebug.h>
|
||||
#include <tfile.h>
|
||||
|
||||
#include "rifffile.h"
|
||||
#include "infotag.h"
|
||||
|
||||
using namespace TagLib;
|
||||
using namespace RIFF::Info;
|
||||
|
||||
namespace
|
||||
{
|
||||
bool isValidChunkID(const ByteVector &name)
|
||||
{
|
||||
if(name.size() != 4)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(name[i] < 32 || 127 < name[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class RIFF::Info::Tag::TagPrivate
|
||||
{
|
||||
public:
|
||||
@ -197,7 +182,7 @@ String RIFF::Info::Tag::fieldText(const ByteVector &id) const
|
||||
void RIFF::Info::Tag::setFieldText(const ByteVector &id, const String &s)
|
||||
{
|
||||
// id must be four-byte long pure ASCII string.
|
||||
if(!isValidChunkID(id))
|
||||
if(!RIFF::File::isValidChunkName(id))
|
||||
return;
|
||||
|
||||
if(!s.isEmpty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user