After long hours of struggling, I have finally found the correct functions to do what I need. After installing the apropriate drivers and a file system, I just called "_io_get_first_valid_fs" to get a valid file system pointer, alloc a memory space for the buffer which receives the files names, open the directory, check if the file system pointer is valid, read the directory content and save the files names into vectors. Then, I close the directory.
I made a smal test in mfs_nandflash_twrk70f120m demo project: I added some code to "shell_task" and I would like to share it. Maybe somebody may find it useful:
void shell_task(uint32_t temp)
{
MQX_FILE_PTR fs_ptr;
char *path_ptr, *mode_ptr;
void *dir_ptr;
char str[100] = "0123456789A";
/* Run the shell on the serial port */
printf("This is the Flash File System example, type help for list of available commands\n");
printf("If this is the first time you use the demo, you should run \"nanderasechip\" command first.\n");
if (_io_nandflash_wl_install(&_bsp_nandflash_wl_init, FFS_DEVICE) != MQX_OK)
{
printf("Can't install FFS!\n");
_task_block();
}
mfs_nandflash_wl_open();
fd = fopen("a:/FILE1.TXT", "a");
if(fd){
fputs(str,fd);
fflush(fd);
fclose(fd);
}
fd = fopen("a:/FILE2.TXT", "a");
if(fd){
fputs(str,fd);
fflush(fd);
fclose(fd);
}
fd = fopen("a:/FILE3.TXT", "a");
if(fd){
fputs(str,fd);
fflush(fd);
fclose(fd);
}
fd = fopen("a:/FILE4.TXT", "a");
if(fd){
fputs(str,fd);
fflush(fd);
fclose(fd);
}
path_ptr ="*.*";
mode_ptr = "m";
fs_ptr = _io_get_first_valid_fs();
temp_buffer = _mem_alloc(BUFFER_SIZE);
dir_ptr = _io_mfs_dir_open(fs_ptr, path_ptr, mode_ptr );
a=0;
b=0;
while ((_io_is_fs_valid(fs_ptr)) && (_io_mfs_dir_read(dir_ptr, temp_buffer, BUFFER_SIZE) > 0)) {
printf(temp_buffer);
while(temp_buffer[a]!=' '){
temp_arquivo[b][a++]=temp_buffer[a++];
}
a=0;
b++;
}
_io_mfs_dir_close(dir_ptr);
for(;;)
{
Shell(Shell_commands, NULL);
printf("Shell exited, restarting...\n");
}
}
My vector receives the files names, as desired:




Now I can read the directory and I don't need to run a Shell.