| Red Hat Documentation: man pages: man3: Linux Programmer's Manual (3) |
FTWSection: Linux Programmer's Manual (3)Updated: July 18, 2025 Index NAMEftw - file tree walkSYNOPSIS#include <ftw.h>int ftw(const char *directory, int (*funcptr )(const char *file, struct stat *sb, int flag), int depth); DESCRIPTIONftw() walks through the directory tree starting from the indicated directory. For each found entry in the tree, it calls funcptr with the full pathname of the entry relative to directory, a pointer to a the second argument is a pointer to the structure for the entry and an int, which value will be one of the following:
ftw() recursively calls itself for traversing found directories. To avoid using up all a program's file descriptors, the depth specifies the number of simultaneous open directories. When the depth is exceeded, ftw() will become slower because directories have to be closed and reopened. To stop the tree walk, funcptr returns a non-zero value; this value will become the return value of ftw(). Otherwise, ftw() will continue until it has traversed the entire tree, in which case it will return zero, or until it hits an error such as a failure, in which case it will return -1. Because ftw() uses dynamic data structures, the only safe way to exit out of a tree walk is to return a non-zero value. To handle interrupts, for example, mark that the interrupt occurred and return a non-zero value---don't use unless the program is going to terminate. CONFORMING TOAES, SVID2, SVID3, XPG2, XPG3, XPG4SEE ALSO
IndexThis document was created by using the manual pages. Time: 11:58:03 GMT, March 24, 2025 |
|
© 2001 Red Hat, Inc. All rights reserved. About Red Hat : Legal statement : Privacy statement : Y2K statement : Contact Red Hat |