Hello,
I am developing an application which scaning files from an usb using chan's filesystem libraries. I want to read all directories recursively and store file names in an array.
It works good but any idea that how can i get files names in an array ?
array string temp_array[50];
var int32 result = 0;
var int32 file_count = 0;
native(temp_array,result,file_count)
{
FRESULT res;
DIR dir;
UINT i;
static FILINFO fno;
static int count = 0;
char scan_file_path[1024];
sprintf(scan_file_path,"%s",(char *)path);
res = f_opendir(&dir, scan_file_path); /* Open the directory */
result = res;
if (result == FR_OK)
{
for (;;)
{
result = f_readdir(&dir, &fno); /* Read a directory item */
if (result != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
if (fno.fattrib & AM_DIR)
{ /* It is a directory */
i = strlen(scan_file_path);
sprintf(&scan_file_path[i], "/%s", fno.fname);
result = FileBrowserFileBrowserWidget_scan_files(_this,scan_file_path);/* Enter the directory */
if (result != FR_OK) break;
scan_file_path[i] = 0;
}
else
{ /* It is a file. */ // THIS IS THE PART THAT I WANT TO STORE
temp_array[count] = EwNewStringUtf8(fno.fname,1024);
count = count + 1;
}
}
f_closedir(&dir);
}
file_count = count;
}
return result;