-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathut.cpp
More file actions
executable file
·169 lines (152 loc) · 4.29 KB
/
Copy pathut.cpp
File metadata and controls
executable file
·169 lines (152 loc) · 4.29 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include "stdio.h"
#include "decodeinfo_mp3.h"
#include "string.h"
#include "scan_dir.h"
#include "iconv.h"
#include "util.h"
extern char *getDir(char *pfile);
extern int switchEncodeToUTF8(char *des, int outlen, char *src, int inlen, char *srcType);
//for test the function
//argv[i] means test the case of index i
//int main(int argc, char *argv[])
int main2()
{
int whichTest = 0;
#if 0
if (argc < 2)
{
printf("the input args is too less!");
}
if (1 == *argv[1])
#endif
//dir_scan.getNextSubFile
if (1 == whichTest)
{
char *path = null;
ScanDir dir_scan("/home/ftp/ftp/t1");
while(path = dir_scan.getNextSubFile())
{
printf("path=%s\n", path);
}
}
//getDir
if (2 == whichTest)
{
char *dir = null;
#if 0
dir = getDir("/home/ftp/ftp/t1/1.mp3");
if (null!=dir)
{
printf("1:dir=%s\n", dir);
printf("strlen=%d\n",strlen(dir));
delete []dir;
}
dir = getDir("/home/ftp/ftp/t1");
if (null!=dir)
{
printf("2:dir=%s\n", dir);
printf("strlen=%d\n",strlen(dir));
delete []dir;
}
dir = getDir("/home/ftp/ftp/t1");
if (null!=dir)
{
printf("3:dir=%s\n", dir);
printf("strlen=%d\n",strlen(dir));
delete []dir;
}
dir = getDir("/home/ftp/ftp/t1/");
if (null!=dir)
{
printf("4:dir=%s\n", dir);
printf("strlen=%d\n",strlen(dir));
delete []dir;
}
dir=getDir("/home/ftp/ftp/t1/你好");
if (null!=dir)
{
printf("5:dir=%s\n", dir);
printf("strlen=%d\n",strlen(dir));
delete []dir;
}
dir = getDir("/home/ftp/ftp/t1/你好/");
if (null!=dir)
{
printf("6:dir=%s\n", dir);
printf("strlen=%d\n",strlen(dir));
delete []dir;
}
dir = getDir("/home/ftp/ftp/t1/你好/1.mp3");
if (null!=dir)
{
printf("7:dir=%s\n", dir);
printf("strlen=%d\n",strlen(dir));
delete []dir;
}
#endif
char *path = "你好/我的歌声里(DEMO).mp3";
dir = getDir(path);
if (null!=dir)
{
printf("8:dir=%s\n", dir);
printf("strlen=%d\n",strlen(dir));
delete []dir;
}
}
//mMp3.getTitle IDV2
if (3 == whichTest)
{
char *path="/home/ftp/ftp/t1/你好/1.mp3";
int titleLen = 0;
enCodeType mencodeType=UTF8;
GetMp3Info mMp3(path);
char *strTitle = mMp3.getTitle(&titleLen, &mencodeType);
if (null == strTitle)
{
printf("strTitle=null:1");
return -1;
}
if ((UTF8 != mencodeType) && (ASCII != mencodeType))
{
char strDecodeTitle[200]={0};
int desLen = 200;
int res = switchEncodeToUTF8(strDecodeTitle, desLen, strTitle, titleLen, strIDV2Encode[mencodeType]);
if (null == strTitle)
{
printf("strTitle=null:2");
return -1;
}
int realLen = strlen(strDecodeTitle);
printf("we get the decoded title:%s", strDecodeTitle);
}
else
{
printf("we get the title:%s", strTitle);
}
delete []strTitle;
}
//getDir
if (4== whichTest)
{
ScanDir dir_scan("/home/ftp/ftp/t1/你好");
char *path;
while(path = dir_scan.getNextSubFile())
{
printf("path is %s", path);
char *strDir = getDir(path);
printf("dir is %s, and the length is %d", strDir, strlen(strDir));
}
}
//convert
if (0 == whichTest)
{
char strDecodeTitle[200]={0};
int desLen=200;
char strTitle[200] = {0xFF, 0xFE,0x60,0x4f,0xc6,0x51,0x07,0x59,0x7d,0x59,0x86,0x4e};
int titleLen=15;
int res = switchEncodeToUTF8(strDecodeTitle, desLen, strTitle, titleLen, "UTF-16");
printf("res=%d\n",res);
printf("the decodetitle is %s\n", strDecodeTitle);
}
return 1;
}