The pf_readdir function reads directory entries.
FRESULT pf_readdir ( DIR* dp, /* [IN] Pointer to the open directory object */ FILINFO* fno /* [OUT] Pointer to the file information structure */ );
The pf_readdir() function reads directory entries in sequence. All items in the directory can be read by calling this function repeatedly. When all directory entries have been read and no item to read, the function returns a null string into member f_name[] in the file information structure without error. When a null pointer is given to the fno, the read index of the directory object will be rewinded.
FRESULT scan_files (char* path) { FRESULT res; FILINFO fno; DIR dir; int i; res = pf_opendir(&dir, path); if (res == FR_OK) { i = strlen(path); for (;;) { res = pf_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) break; if (fno.fattrib & AM_DIR) { sprintf(&path[i], "/%s", fno.fname); res = scan_files(path); if (res != FR_OK) break; path[i] = 0; } else { printf("%s/%s\n", path, fno.fname); } } } return res; }
Available when _USE_DIR == 1.