[libc-commits] [libc] [libc] Implement scandir and its unit tests (PR #223198)
Vadim Kotov via libc-commits
libc-commits at lists.llvm.org
Mon Sep 28 12:57:35 PDT 2026
================
@@ -78,8 +78,15 @@ class Dir {
public:
static ErrorOr<Dir *> open(const char *path);
static ErrorOr<Dir *> fdopen(int fd);
-
ErrorOr<struct dirent *> read();
+ static ErrorOr<int> scan(const char *name, struct dirent ***namelist,
+ int (*filter)(const struct dirent *),
+ int (*compare)(const struct dirent **,
+ const struct dirent **));
+
+ LIBC_INLINE static size_t reclen(struct dirent *d) {
----------------
vadimkotov wrote:
I was just trying to follow the logic of dependency injection: I didn't want `scan_impl.h` depend on `dir.h`, I thought that would be a bit cleaner and reduce a risk of circular dependencies if we decide move things around in the future (though right now it may be safe to do...).
https://github.com/llvm/llvm-project/pull/223198
More information about the libc-commits
mailing list