0664jester
Mitglied
Hallo,
Ich habe hier eine Funktion, die ich nicht ganz verstehe.
Es geht darum, dass man für id3 tags und .m3u dateien überprüfen muss, ob überhaupt mp3 dateien vorhanden sind.
dadurch da j und k ist kenn ich mich nicht gerade gut aus... was da überhaupt gmeacht wird und warum
pos = strcspn(string, "#" ); da die raute wichtig ist
Ich habe hier eine Funktion, die ich nicht ganz verstehe.
Es geht darum, dass man für id3 tags und .m3u dateien überprüfen muss, ob überhaupt mp3 dateien vorhanden sind.
dadurch da j und k ist kenn ich mich nicht gerade gut aus... was da überhaupt gmeacht wird und warum
pos = strcspn(string, "#" ); da die raute wichtig ist
Code:
char* checkSongFilesExists(char* puffer, FILE* genre_file)
{
char string[strlen( puffer+1 )];
strcpy(string,puffer);
string[strlen(puffer)] = '\0';
int pos = 0, j = 0, k = 0, size_temp = 1, loop_control = 0;
FILE *songtitle_file;
while (size_temp > 0)
{
pos = strcspn(string, "#" );
size_temp = (strlen(string) - pos);
char temp_songtitle[size_temp];
j = pos + 1;
k = 0;
while (k < size_temp)
{
temp_songtitle[k] = string[j];
k++;
j++;
}
temp_songtitle[k] = '\0';
char songtitle[pos + 1];
strncpy(songtitle, string, pos);
songtitle[pos] = '\0';
songtitle_file = fopen(songtitle, "r");
if (CheckFileCanBeOpened(songtitle_file, songtitle) != 0)
{
int i = pos + 1;
k = 0;
if (loop_control == 0)
{
i = 0;
}
while (k < (strlen (temp_songtitle)))
{
puffer[i] = temp_songtitle[k];
i++;
k++;
}
puffer[i++] = '\0';
}
else
{
getDataforList(songtitle, songtitle_file, genre_file);
}
strcpy(string,temp_songtitle);
string[size_temp] = '\0';
size_temp = (strlen(string) - pos);
loop_control = 1;
}
return puffer;
}