arch/sim/src/sim/up_hostfs.c: hostfs skip '.' and '..' in readdir'
This commit is contained in:
parent
3bc62f1ccc
commit
9f0502f8ba
@ -292,11 +292,24 @@ int host_readdir(void* dirp, struct nuttx_dirent_s* entry)
|
||||
{
|
||||
struct dirent *ent;
|
||||
|
||||
/* Call the host's readdir routine */
|
||||
|
||||
ent = readdir(dirp);
|
||||
if (ent != NULL)
|
||||
for (; ; )
|
||||
{
|
||||
/* Call the host's readdir routine */
|
||||
|
||||
ent = readdir(dirp);
|
||||
if (ent == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* Skip '.' and '..' */
|
||||
|
||||
if (ent->d_name[0] == '.' && (ent->d_name[1] == '\0' ||
|
||||
(ent->d_name[1] == '.' && ent->d_name[2] == '\0')))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Copy the entry name */
|
||||
|
||||
strncpy(entry->d_name, ent->d_name, sizeof(entry->d_name));
|
||||
|
Loading…
Reference in New Issue
Block a user