1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 12:37:44 +00:00

LibC: Implement scandir(...) to enumerate directories.

I ran into a need for this when running  stress-ng against the system.
This change implements the full functionality of scandir, where it
accepts a selection callback, as well as a comparison callback.
These can be used to trim and sort the entries from the directory
that we are being asked to enumerate. A test was also included to
validate the new functionality.
This commit is contained in:
Brian Gianforcaro 2021-05-02 02:36:59 -07:00 committed by Andreas Kling
parent d4d988532a
commit 331ab52318
4 changed files with 95 additions and 0 deletions

View file

@ -55,4 +55,8 @@ struct dirent* readdir(DIR*);
int readdir_r(DIR*, struct dirent*, struct dirent**);
int dirfd(DIR*);
int scandir(const char* dirp, struct dirent*** namelist,
int (*filter)(const struct dirent*),
int (*compar)(const struct dirent**, const struct dirent**));
__END_DECLS