bool CMP3AudioTag::Read(std::string filename)
{
char header[4] = { 0 };
char title[31] = { 0 };
char artist[31] = { 0 };
char album[31] = { 0 };
char year[5] = { 0 };
char comment[31] = { 0 };
char genre = 0;
int handle = open(filename.c_str(), O_RDONLY);
lseek(handle, -128L, SEEK_END);
read(handle, header, 3);
bool result = false;
if (!stricmp(header, "TAG")) {
// valid header... this MP3 has an audio tag!
read(handle, title, 30); m_Title = title;
read(handle, artist, 30); m_Artist = artist;
read(handle, album, 30); m_Album = album;
read(handle, year, 4); m_Year = year;
read(handle, comment, 30); m_Comment = comment;
read(handle, &genre, 1);
m_Genre = (MP3_GENRE)genre;
m_GenreStr = GenreToString(m_Genre);
result = true;
}
close(handle);
return(result);
}
{
char header[4] = { 0 };
char title[31] = { 0 };
char artist[31] = { 0 };
char album[31] = { 0 };
char year[5] = { 0 };
char comment[31] = { 0 };
char genre = 0;
int handle = open(filename.c_str(), O_RDONLY);
lseek(handle, -128L, SEEK_END);
read(handle, header, 3);
bool result = false;
if (!stricmp(header, "TAG")) {
// valid header... this MP3 has an audio tag!
read(handle, title, 30); m_Title = title;
read(handle, artist, 30); m_Artist = artist;
read(handle, album, 30); m_Album = album;
read(handle, year, 4); m_Year = year;
read(handle, comment, 30); m_Comment = comment;
read(handle, &genre, 1);
m_Genre = (MP3_GENRE)genre;
m_GenreStr = GenreToString(m_Genre);
result = true;
}
close(handle);
return(result);
}
回复Comments
作者:
{commentrecontent}