Index: apps/playlist.c =================================================================== --- apps/playlist.c (revision 17722) +++ apps/playlist.c (working copy) @@ -3535,89 +3535,43 @@ int (*callback)(char*, void*), void* context) { - char buf[MAX_PATH+1]; int result = 0; - int num_files = 0; - int i; - struct entry *files; - struct tree_context* tc = tree_get_context(); - int old_dirfilter = *(tc->dirfilter); - - if (!callback) - return -1; - - /* use the tree browser dircache to load files */ - *(tc->dirfilter) = SHOW_ALL; - - if (ft_load(tc, dirname) < 0) + DIR* dir; + char buf[MAX_PATH+1]; + int dirlen = strlen(dirname); + char *filename = buf + dirlen; + strcpy(buf, dirname); + + dir = opendir(dirname); + if (!dir) + return 0; + while (result == 0) { - gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR)); - *(tc->dirfilter) = old_dirfilter; - return -1; - } - - files = (struct entry*) tc->dircache; - num_files = tc->filesindir; - - /* we've overwritten the dircache so tree browser will need to be - reloaded */ - reload_directory(); - - for (i=0; id_name); + printf("%s\n", buf); + if (recurse && entry->attribute & ATTR_DIRECTORY) { - if (recurse) - { - /* recursively add directories */ - snprintf(buf, sizeof(buf), "%s/%s", dirname, files[i].name); - result = playlist_directory_tracksearch(buf, recurse, - callback, context); - if (result < 0) - break; - - /* we now need to reload our current directory */ - if(ft_load(tc, dirname) < 0) - { - result = -1; - break; - } - - files = (struct entry*) tc->dircache; - num_files = tc->filesindir; - if (!num_files) - { - result = -1; - break; - } - } - else + if (!strcmp((char *)entry->d_name, ".") || + !strcmp((char *)entry->d_name, "..")) continue; + result = playlist_directory_tracksearch(buf, recurse, + callback, context); } - else if ((files[i].attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) + else { - snprintf(buf, sizeof(buf), "%s/%s", dirname, files[i].name); - - if (callback(buf, context) != 0) + if (filetype_get_attr(buf) == FILE_ATTR_AUDIO) { - result = -1; - break; + result = callback(buf, context); } - - /* let the other threads work */ - yield(); } + *filename = '\0'; + yield(); + /* check for user abort */ + result = action_userabort(TIMEOUT_NOBLOCK)?-1:0; } - - /* restore dirfilter */ - *(tc->dirfilter) = old_dirfilter; - + closedir(dir); return result; }