eclipse-threadx/filex

why fx_directory_next_full_entry_find can't call twice?

Closed this issue · 2 comments

TMODER commented

i try to using fx_directory_next_full_entry_find to traverse a directory and print result ,but when call this function again then no result.
maybe need clear somthing,but find nothing。the demo like this:

UINT attributes,year,month,day,hour,minute,second,cnt;
ULONG size;
for (cnt = 0; ;cnt++)
{
memset(response_buf, 0, 512);
status = fx_directory_next_full_entry_find (media,
entry_name,
&attributes,
&size,
&year, &month, &day,
&hour, &minute, &second);
if(status != FX_SUCCESS || entry_name[0] == 0)
{
break;
}
if(entry_name[0] == '.')
{
continue;
}
if (attributes & FX_DIRECTORY)
{
snprintf(response_buf, 512,"%s\r\n",entry_name);
}
else
{
snprintf(response_buf, 512,"%s,%ld\r\n",entry_name,size);
}
printf(response_buf);
}
return;

@TMODER fx_directory_first_full_entry_find() should be called to find the first entry and call fx_directory_next_full_entry_find() to find the next entry. fx_directory_next_entry_find() will return success until the last entry and when you try to call the function one past the number of entries it will return error (FX_NO_MORE_ENTRIES)

TMODER commented

@bhnaphade THKS ,it works! I misunderstood the interface,like opendir()、readdir() and closedir() in Linux!