Walking a Directory Structure
Some UNIX platforms provide the function ftw(3C) and the newer function nftw(3C) to make it simpler to perform a tree walk of a file system. These functions do not appear on the FreeBSD system, so only a cursory description of them will be provided here. The HPUX-11 ftw(3C) page provides this function synopsis:
#include <ftw.h> int ftw (const char *path, int (*fn)(const char *obj_path, const struct stat *obj_stat, int obj_flags), int depth); int nftw (const char *path, int (*fn)(const char *obj_path, const struct stat *obj_stat, int obj_flags, struct FTW obj_FTW), int depth, int flags);
These functions start by examining the directory provided by the argument path. From this point on, the directory is recursively ...
Get Advanced UNIX Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.