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
| int exploreDirectory(char *currentDir, MUSICDATA *data)
{
WIN32_FIND_DATA foundData;
HANDLE search;
char temp[512];
strcpy(temp, currentDir);
findFilePath(temp);
search = FindFirstFile(currentDir, &foundData);
if (search == INVALID_HANDLE_VALUE)
return 0;
for(int i = 1 ; ; i++)
{
if((FindNextFile(search, &foundData)==0) && (GetLastError() == ERROR_NO_MORE_FILES))
break;
if(foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
char temp2[512];
if((strcmp(foundData.cFileName,"..") == 0) || (strcmp(foundData.cFileName,"WINDOWS") == 0))
continue;
strcpy(temp2,temp);
strcat(temp2, "\\");
strcat(temp2, foundData.cFileName);
strcat(temp2, "\\*.*");
exploreDirectory(temp2, data);
}
else if(((strstr(foundData.cFileName, ".mp3")!=NULL) ||
(strstr(foundData.cFileName, ".wav")!=NULL) ||
(strstr(foundData.cFileName, ".wma")!=NULL) ||
(strstr(foundData.cFileName, ".ogg")!=NULL))&&(strstr(foundData.cFileName, ".lnk")==NULL))
{
strcpy(data->path[data->numberItems], temp);
strcat(data->path[data->numberItems], "\\");
strcat(data->path[data->numberItems], foundData.cFileName);
strcpy(data->name[data->numberItems], foundData.cFileName);
data->numberItems++;
}
}
FindClose(search);
return 1;
} |
Partager