Open System Services Library Calls Reference Manual (G06.28+, H06.05+)
ftw(3) OSS Library Calls Reference Manual
NAME
ftw - Traverses a file tree
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossesrl
H-series OSS processes: /G/system/zdllnnn/zossedll
SYNOPSIS
#include <ftw.h>
int ftw(
const char *path,
int(*function)(const char *object,
const struct stat *ptr,
int flag),
int ndirs);
PARAMETERS
path Points to the directory hierarchy to be searched.
function Points to the function to be invoked for each file in the directory hierarchy.
object Points to the name of the next file in the directory hierarchy specified in the path
parameter. This name must be a null-terminated string.
ptr Points to a stat structure, as defined in the sys/stat.h header file. The stat struc-
ture contains information about the file specified in the object parameter.
flag Specifies the type of file. See DESCRIPTION.
ndirs Indicates the maximum number of directory streams, file descriptors, or both
available for use by the ftw() function while traversing the tree. This parameter
is ignored in the OSS implementation.
DESCRIPTION
The ftw() function recursively searches the directory hierarchy that descends from the directory
specified by the path parameter.
For each file in the hierarchy, ftw() calls the function pointed to by the function parameter,
passes it a pointer to a null-terminated character string containing the name of the file, a pointer
to a stat structure containing information about the file, and an integer flag value.
The flag value passed to the function parameter identifies the file type. The flag value can be one
of the following:
FTW_D Directory
FTW_DNR Directory that cannot be read
FTW_F Regular file
FTW_NS A file for which the stat() function could not be executed successfully
FTW_SL Symbolic link
If flag is FTW_DNR, the files and subdirectories contained in that directory are not processed.
If flag is FTW_NS, the stat structure contents are meaningless. An example of a file that causes
FTW_NS to be passed to the function parameter is a file in a directory for which you have read
permission but not execute (search) permission. This condition also returns the value [EACCES]
in errno.
2−144 Hewlett-Packard Company 527187-007