DCL 4.0
Loading...
Searching...
No Matches
TagCounter Class Reference

#include <TagCounter.h>

Public Member Functions

 TagCounter ()
void operator+= (const TagCounter _x)
String toString () const

Static Public Member Functions

static void read (const String &_filename, TagCounter &_counter)
static void readDir (const String &_path, TagCounter &_counter, const MainArguments &_args)

Public Attributes

int ID3v1
int ID3v22
int ID3v23
int ID3v24
int APEv1
int APEv2
int error

Detailed Description

Definition at line 12 of file TagCounter.h.

Constructor & Destructor Documentation

◆ TagCounter()

TagCounter::TagCounter ( )
inline

Definition at line 15 of file TagCounter.h.

15 {
16 ID3v1 = ID3v22 = ID3v23 = ID3v24 = APEv1 = APEv2 = error = 0;
17 }

Member Function Documentation

◆ operator+=()

void TagCounter::operator+= ( const TagCounter _x)
inline

Definition at line 19 of file TagCounter.h.

19 {
20 ID3v1 += _x.ID3v1;
21 ID3v22 += _x.ID3v22;
22 ID3v23 += _x.ID3v23;
23 ID3v24 += _x.ID3v24;
24 APEv1 += _x.APEv1;
25 APEv2 += _x.APEv2;
26 }

◆ read()

__DCL_BEGIN_NAMESPACE void TagCounter::read ( const String & _filename,
TagCounter & _counter )
static

Definition at line 38 of file TagCounter.cpp.

39{
40 File file(_filename);
41 char buf[160]; // 128 + 32
42
43 int idv2 = 0;
44 int ape = 0;
45 int idv1 = 0;
46
47 // 파일의 시작에서 ID3v2와 APEv2를 검사한다.
48 // "ID3" "APETAGEX"
49 size_t n = file.read(buf, 32);
50 if (n == 32) {
51 if (memcmp(buf, "ID3", 3) == 0) {
52 idv2 = buf[3];
53 }
54 else if (memcmp(buf, "APETAGEX", 8) == 0) {
55 ape = APEv2::word(&buf[8]) / 1000;
56 }
57 }
58
59 // 파일의 끝에서 APEv2와 ID3v1을 검사한다.
60 file.seek(-160, File::END);
61 n = file.read(buf, 160);
62 if (n == 160) {
63 if (ape == 0) {
64 if (memcmp(buf, "APETAGEX", 8) == 0) {
65 ape = APEv2::word(&buf[8]) / 1000;
66 }
67 else if (memcmp(&buf[128], "APETAGEX", 8) == 0) {
68 ape = APEv2::word(&buf[128 + 8]) / 1000;
69 }
70 }
71
72 if (memcmp(&buf[32], "TAG", 3) == 0) {
73 idv1 = 1;
74 }
75 }
76
77 switch (idv2) {
78 case 2:
79 _counter.ID3v22++;
80 break;
81 case 3 :
82 _counter.ID3v23++;
83 break;
84 case 4 :
85 _counter.ID3v24++;
86 }
87
88 switch (ape) {
89 case 1:
90 _counter.APEv1++;
91 break;
92 case 2:
93 _counter.APEv2++;
94 }
95
96 if (idv1 == 1) {
97 _counter.ID3v1++;
98 }
99}
ByteBuffer * buf
void CharsetConvertException *size_t n
Definition SQLField.cpp:253
@ END
Definition File.h:207

◆ readDir()

void TagCounter::readDir ( const String & _path,
TagCounter & _counter,
const MainArguments & _args )
static

Definition at line 101 of file TagCounter.cpp.

103{
104 Dir dir(_path);
105 Dir::Entry entry;
106
107 while (dir.read(entry)) {
108 String name = entry.name();
109 if (entry.isDir()) {
110 if (name.compare(L"..", name.length()) != 0) {
111 String path = dir.path() + name;
112 TagCounter counter;
113 TagCounter::readDir(path, counter, _args);
114 _counter += counter;
115 if (_args.verbose()) {
116 _args.output() << L"[" << path << L"] " << counter.toString() << endl;
117 }
118 }
119 }
120 else {
121 if (name.toLowerCase().endsWith(L".mp3")) {
122 try {
123 TagCounter counter;
124 TagCounter::read(dir.path() + name, counter);
125 _counter += counter;
126 if (_args.verbose()) {
127 _args.output() << L"[ " << name << L"] " << counter.toString() << endl;
128 }
129 }
130 catch (Exception* e) {
131 _counter.error++;
132 _args.errout() << e->toStringAll() << endl;
133 e->destroy();
134 }
135 }
136 }
137 }
138}
#define endl
virtual void destroy()
Definition Exception.cpp:74
String toStringAll() const
Definition Exception.cpp:45
bool verbose() const
static void read(const String &_filename, TagCounter &_counter)
String toString() const
Definition TagCounter.h:28
static void readDir(const String &_path, TagCounter &_counter, const MainArguments &_args)

◆ toString()

String TagCounter::toString ( ) const
inline

Definition at line 28 of file TagCounter.h.

28 {
29 return String::format(L""
30 "ID3v1[%d] ID3v22[%d] ID3v23[%d] ID3v24[%d] APEv1[%d] APEv2[%d] error[%d]",
32 );
33 }

Member Data Documentation

◆ APEv1

int TagCounter::APEv1

Definition at line 39 of file TagCounter.h.

◆ APEv2

int TagCounter::APEv2

Definition at line 40 of file TagCounter.h.

◆ error

int TagCounter::error

Definition at line 41 of file TagCounter.h.

◆ ID3v1

int TagCounter::ID3v1

Definition at line 35 of file TagCounter.h.

◆ ID3v22

int TagCounter::ID3v22

Definition at line 36 of file TagCounter.h.

◆ ID3v23

int TagCounter::ID3v23

Definition at line 37 of file TagCounter.h.

◆ ID3v24

int TagCounter::ID3v24

Definition at line 38 of file TagCounter.h.


The documentation for this class was generated from the following files: