3 ms·
In POSIX, there are two sets of functions related to directories. The first set, `opendir()` (open a directory for reading), `readdir()` (return next filename
by spc476 8y ago
In POSIX, there are two sets of functions related to directories. The first set, `opendir()` (open a directory for reading), `readdir()` (return next filename upon each call) and `closedir()` (close the directory). `readdir()` does not guarantee an ordering of filenames and any filtering must be done by the application.
Then there's `wordexp()` and `wordfree()`. The first takes a file glob (file pattern?) and returns an array of filenames matching the pattern. Any memory allocated by `wordexp()` is freed by calling `wordfree()`.
Both have their uses.