Open System Services Library Calls Reference Manual (G06.28+, H06.05+)

ftw(3) OSS Library Calls Reference Manual
NAME
ftw - Traverses a le 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 ag),
int ndirs);
PARAMETERS
path Points to the directory hierarchy to be searched.
function Points to the function to be invoked for each le in the directory hierarchy.
object Points to the name of the next le in the directory hierarchy specied in the path
parameter. This name must be a null-terminated string.
ptr Points to a stat structure, as dened in the sys/stat.h header le. The stat struc-
ture contains information about the le specied in the object parameter.
flag Species the type of le. See DESCRIPTION.
ndirs Indicates the maximum number of directory streams, le 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
specied by the path parameter.
For each le 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 le, a pointer
to a stat structure containing information about the le, and an integer ag value.
The ag value passed to the function parameter identies the le type. The ag value can be one
of the following:
FTW_D Directory
FTW_DNR Directory that cannot be read
FTW_F Regular le
FTW_NS A le for which the stat() function could not be executed successfully
FTW_SL Symbolic link
If ag is FTW_DNR, the les and subdirectories contained in that directory are not processed.
If ag is FTW_NS, the stat structure contents are meaningless. An example of a le that causes
FTW_NS to be passed to the function parameter is a le in a directory for which you have read
permission but not execute (search) permission. This condition also returns the value [EACCES]
in errno.
2144 Hewlett-Packard Company 527187-007