diff options
-rw-r--r-- | Userland/Libraries/LibC/dirent.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibC/dirent.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/dirent.cpp b/Userland/Libraries/LibC/dirent.cpp index 90cd7ed25f..fe902a32ce 100644 --- a/Userland/Libraries/LibC/dirent.cpp +++ b/Userland/Libraries/LibC/dirent.cpp @@ -222,6 +222,12 @@ int dirfd(DIR* dirp) return dirp->fd; } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/alphasort.html +int alphasort(const struct dirent** d1, const struct dirent** d2) +{ + return strcoll((*d1)->d_name, (*d2)->d_name); +} + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/scandir.html int scandir(const char* dir_name, struct dirent*** namelist, diff --git a/Userland/Libraries/LibC/dirent.h b/Userland/Libraries/LibC/dirent.h index 1e3f8534cc..7d0b1bf2d2 100644 --- a/Userland/Libraries/LibC/dirent.h +++ b/Userland/Libraries/LibC/dirent.h @@ -35,6 +35,7 @@ struct dirent* readdir(DIR*); int readdir_r(DIR*, struct dirent*, struct dirent**); int dirfd(DIR*); +int alphasort(const struct dirent** d1, const struct dirent** d2); int scandir(const char* dirp, struct dirent*** namelist, int (*filter)(const struct dirent*), int (*compar)(const struct dirent**, const struct dirent**)); |