Unify common functions for finding tags.

Several classes have exactly identical functions for finding tags.
This also hides the functions from public headers.
This commit is contained in:
Tsuda Kageyu
2015-11-21 09:30:04 +09:00
parent ce1c03faa3
commit b592f78238
13 changed files with 146 additions and 201 deletions

View File

@ -28,6 +28,7 @@
#include <tagunion.h>
#include <tdebug.h>
#include <tpropertymap.h>
#include <tagutils.h>
#include "mpcfile.h"
#include "id3v1tag.h"
@ -266,7 +267,7 @@ void MPC::File::read(bool readProperties)
{
// Look for an ID3v1 tag
d->ID3v1Location = findID3v1();
d->ID3v1Location = Utils::findID3v1(this);
if(d->ID3v1Location >= 0) {
d->tag.set(MPCID3v1Index, new ID3v1::Tag(this, d->ID3v1Location));
@ -275,7 +276,7 @@ void MPC::File::read(bool readProperties)
// Look for an APE tag
d->APELocation = findAPE();
d->APELocation = Utils::findAPE(this, d->ID3v1Location);
if(d->APELocation >= 0) {
d->tag.set(MPCAPEIndex, new APE::Tag(this, d->APELocation));
@ -290,7 +291,7 @@ void MPC::File::read(bool readProperties)
// Look for an ID3v2 tag
d->ID3v2Location = findID3v2();
d->ID3v2Location = Utils::findID3v2(this);
if(d->ID3v2Location >= 0) {
seek(d->ID3v2Location);
@ -323,48 +324,3 @@ void MPC::File::read(bool readProperties)
d->properties = new Properties(this, streamLength);
}
}
long MPC::File::findAPE()
{
if(!isValid())
return -1;
if(d->hasID3v1)
seek(-160, End);
else
seek(-32, End);
long p = tell();
if(readBlock(8) == APE::Tag::fileIdentifier())
return p;
return -1;
}
long MPC::File::findID3v1()
{
if(!isValid())
return -1;
seek(-128, End);
long p = tell();
if(readBlock(3) == ID3v1::Tag::fileIdentifier())
return p;
return -1;
}
long MPC::File::findID3v2()
{
if(!isValid())
return -1;
seek(0);
if(readBlock(3) == ID3v2::Header::fileIdentifier())
return 0;
return -1;
}

View File

@ -222,9 +222,6 @@ namespace TagLib {
File &operator=(const File &);
void read(bool readProperties);
long findAPE();
long findID3v1();
long findID3v2();
class FilePrivate;
FilePrivate *d;