summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC/dirent.cpp
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-12-27 19:26:37 -0800
committerAndreas Kling <kling@serenityos.org>2021-12-28 11:00:51 +0100
commitc4b1e490369aa79cd79b79f0c41135244a7186e7 (patch)
tree6916f19fe790dfc53f8a1860ad1a9c90a55e450a /Userland/Libraries/LibC/dirent.cpp
parentfa5d81be7a858bf7db70c4126b29053300d938ce (diff)
downloadserenity-c4b1e490369aa79cd79b79f0c41135244a7186e7.zip
LibC: Add alphasort() implementation
This is a POSIX API required for the latest stress-ng port.
Diffstat (limited to 'Userland/Libraries/LibC/dirent.cpp')
-rw-r--r--Userland/Libraries/LibC/dirent.cpp6
1 files changed, 6 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,