Skip to content

<dirent.h>

Minimal opendir/readdir/closedir for tier-2 (newlib) programs.

newlib's own refuses to build on this target, so this header shadows it. lib/posix/dirent.c implements it with FsdReadDir().

#include <dirent.h>

Types

Type Definition Description
DIR struct DIR An open directory; opaque.

Structures

dirent

One directory entry.

Field Type Description
d_type unsigned char An FsdFileType.
d_name char NUL-terminated name, as in FsdDirEntry.

Functions

opendir

DIR * opendir(const char *path);

Opens a directory for reading.

Parameter Direction Description
path in Directory path.

Returns: The directory, or NULL with errno set.

readdir

struct dirent * readdir(DIR *dirp);

Returns the next entry.

Parameter Direction Description
dirp inout Directory from opendir().

Returns: The entry, valid until the next call, or NULL at the end.

closedir

int closedir(DIR *dirp);

Closes a directory.

Parameter Direction Description
dirp in Directory from opendir().

Returns: 0.