Best way to read directories?
While historically there have been several different interfaces for
this, the only one that really matters these days the the Posix.1
standard `<dirent.h>' functions.
The function opendir()
opens a specified directory;
readdir()
reads directory entries from it in a standardised
format; closedir()
does the obvious. Also provided are
rewinddir()
, telldir()
and seekdir()
which should
also be obvious.
If you are looking to expand a wildcard filename, then most systems have
the glob()
function; also check out fnmatch()
to match
filenames against a wildcard, or ftw()
to traverse entire
directory trees.
Home | FAQ |