limb 0.2.0

2024-01-09

sa_scandirat(3)
limb manual
sa_scandirat(3)

NAME

sa_scandirat, sa_scandir - scan a directory to fill a stralloc

SYNOPSIS

#include <fcntl.h> /* AT_FDCWD */
#include <limb/direntry.h>
typedef ssize_t (*sa_scande) (stralloc *sa, direntry *de, int dirfd, void *ctx)

int sa_scandirat(stralloc *sa, int dirfd, const char *name, sa_scande fn, void *ctx)
int sa_scandir(stralloc *sa, const char *name, sa_scande fn, void *ctx)

DESCRIPTION

The sa_scandirat() function scans the directory name calling the function fn on each of its directory entry, save for . and .. which are ignored. Said function shall add relevant information regarding the directory entry pointed by de into the stralloc pointed by sa and return 1 on success. It can also return 0 if nothing was added, e.g. the file/entry was simply ignored. In case of failure it must return -1 and set errno to indicate the error.

If name describes a relative path, it is relative to the directory associated with the file descriptor dirfd, which may be AT_FDCWD to use the current working directory.

The sa_scandir() macro is similar, except when name describes a relative path, in which case it is relative to the current working directory.

RETURN VALUE

These functions returns the number of entries for which data was added into sa on success. Otherwise it returns -1 and sets errno to indicate the error.

ERRORS

These functions may fail and set errno for the error described for opendirat(3), readdir(3), as well as those set by the function fn.

limb 0.1.0
2023-07-24
sa_scandirat(3)