I'm terrbly sorry to have to bother again, with probebly such trivial
questions.
But i just don't get it.
-The code that i'm talking about is at the end of this question.-
I have a object called track which stores 2 variables and has a few
methodes.
basicly it is to supply the program with information about a specific
mp3 file.
(one instance per mp3 will be created in the program with the piece of
code labeld A1)
Such a track object (code at A2) is generated at start up when all mp3
file paths are put into a text file and then read out by the object
hoofd_lijst (main list) This becouse it looked to me as the most
efficiant and fast way to do it. since (locate | grep) will be much
faster then i could ever code
it.
The program compiles&links fine, Yet when i run it, it segfaults on the
set_path methode in the track object.
I'm suspecting that i declared something wrongly, or i'm calling the
function to soon or too early.
Or i'm trying to do something that's impossible?
I'm basicly at a total loss. I have no real idea how to fix the sigfault
except by commenting the "ID3Tag_Link(tag, new_path.c_str());" line out
of the set_path methode in the track object.
I hope someone could help me with this. becouse i would love to see it
all work, yet i just don't understand it good enough yet.
(also my appologie for my bad english and grammer)
A1: The list filling methode in the object called hoofd_lijst
(translated main_list)
It takes the paths from the file and gives them to the tmp track object
to pass them on to a vector of tracks.
(declared as "vector <track> mp3;" in private.)
-------==========--------------
void fill_list(){
track tmp;
char tmp1[1024];
system("locate mp3 | grep '\.mp3$' > mp3_list.dat");
system("locate mp3 | grep '\.MP3$' >> mp3_list.dat");
ifstream mp3_buff;
mp3_buff.open("mp3_list.dat");
while (mp3_buff.getline(tmp1, 1024)) {
tmp.set_path(tmp1);
mp3.push_back(tmp);
cout << mp3.size() << " - " << tmp1 <<
'\n';
}
mp3_buff.close();
cout << "\n-|| " << mp3.size() << " Mp3's read into
database. ||-" << "\n\n";
}
--------==========-------------
A2: this is the track object, it mainly has 2 types of methodes.
1 to set the path, and thus telling it, which mp3 it represents.
and a whole heap of other methodes that give back information about that
mp3. (only 2 coded yet, the one to give back the path of the mp3. and
one that isn't realy working. (as far as i can know))
--------==========-------------
class track{
public:
track(){
}
void set_path(string new_path){
this->path = new_path;
cout << "begin";
ID3Tag_Link(tag, new_path.c_str());
cout << "end";
}
string get_path(){
return path;
}
string get_title(){
string tmp;
cout << "start\n";
//if ((frame = ID3Tag_FindFrameWithID((const ID3Tag *)tag,
ID3FID_ALBUM)) != NULL)
if ((frame = ID3Tag_FindFrameWithID(tag, ID3FID_ALBUM)) != NULL)
{
if ((field = ID3Frame_GetField(frame, ID3FN_TEXT)) !=
NULL)
{
char album[1024];
ID3Field_GetASCII(field, album, 1024);
printf("Album: %s\n", album);
}
else
{
printf("Didn't get the field\n");
}
}
else
{
printf("Didn't get the frame\n");
}
cout << "stop\n";
}
private:
string path;
ID3Tag *tag;
ID3Frame *frame;
ID3Field *field;
};
--------------=============------------
|