diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-05-02 02:36:59 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-02 13:33:41 +0200 |
commit | 331ab52318033e2385f77b0d92e173376a701127 (patch) | |
tree | 5f87f9fbde4ed36f1ac37ec350516194d0e7d664 /Userland/Libraries/LibC/dirent.h | |
parent | d4d988532a07a49520f20d00bc431415e86cec50 (diff) | |
download | serenity-331ab52318033e2385f77b0d92e173376a701127.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibC/dirent.h')
-rw-r--r-- | Userland/Libraries/LibC/dirent.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/dirent.h b/Userland/Libraries/LibC/dirent.h index d468e33e6c..149dd122dc 100644 --- a/Userland/Libraries/LibC/dirent.h +++ b/Userland/Libraries/LibC/dirent.h @@ -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 |