[libc] Implement scandir and its unit tests (#223198)

scandir is a POSIX function from <dirent.h> header that scans the directory and returns all files
contained within, optionally applying user-provided filtering and comparator functions.

Provide implementation which allows substituting the `Dir` class to allow for dependency
injection to cover various error cases.

GitOrigin-RevId: 05390247f59c9f3eddda8f0613fa193b128539a4
15 files changed