-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtagutils.cpp
More file actions
79 lines (61 loc) · 2.54 KB
/
Copy pathtagutils.cpp
File metadata and controls
79 lines (61 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/***************************************************************************
copyright : (C) 2015 by Tsuda Kageyu
email : tsuda.kageyu@gmail.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <tfile.h>
#include "id3v1tag.h"
#include "id3v2header.h"
#include "apetag.h"
#include "tagutils.h"
using namespace TagLib;
long Utils::findID3v1(File *file)
{
if(!file->isValid())
return -1;
file->seek(-128, File::End);
const long p = file->tell();
if(file->readBlock(3) == ID3v1::Tag::fileIdentifier())
return p;
return -1;
}
long Utils::findID3v2(File *file)
{
if(!file->isValid())
return -1;
file->seek(0);
if(file->readBlock(3) == ID3v2::Header::fileIdentifier())
return 0;
return -1;
}
long Utils::findAPE(File *file, long id3v1Location)
{
if(!file->isValid())
return -1;
if(id3v1Location >= 0)
file->seek(id3v1Location - 32, File::Beginning);
else
file->seek(-32, File::End);
const long p = file->tell();
if(file->readBlock(8) == APE::Tag::fileIdentifier())
return p;
return -1;
}