ftw.h File Reference

FTW_F

Regular File. Valid flags for the 3rd argument to the function that is passed as the second argument to ftw(3) and nftw(3).

FTW_D

Valid flags for the 3rd argument to the function that is passed as the second argument to ftw(3) and nftw(3). Directory.

FTW_DNR

Valid flags for the 3rd argument to the function that is passed as the second argument to ftw(3) and nftw(3). Directory without read permission.

FTW_DP

Valid flags for the 3rd argument to the function that is passed as the second argument to ftw(3) and nftw(3). Directory with subdirectories visited. A file on which stat could not successfully be executed.

FTW_NS

Valid flags for the 3rd argument to the function that is passed as the second argument to ftw(3) and nftw(3). A file on which stat could not successfully be executed.

FTW_SL

Valid flags for the 3rd argument to the function that is passed as the second argument to ftw(3) and nftw(3). Symbolic link.

FTW_SLN

Valid flags for the 3rd argument to the function that is passed as the second argument to ftw(3) and nftw(3). Sym link that names a nonexistent file.

FTW_PHYS

Flags for use as the 4th argument to nftw(3). These may be ORed together. Physical walk, don't follow sym links.

FTW_MOUNT

Flags for use as the 4th argument to nftw(3). These may be ORed together. The walk does not cross a mount point.

FTW_DEPTH

Flags for use as the 4th argument to nftw(3). These may be ORed together. Subdirs visited before the dir itself.

FTW_CHDIR

Flags for use as the 4th argument to nftw(3). These may be ORed together. Change to a directory before reading it.

ftw ( const char *, int(*)(const char *, const struct stat *, int), int )

IMPORT_C intftw(const char *,
int(*)(const char *, const struct stat *, int),
int
)

The ftw() function shall recursively descend the directory hierarchy rooted in path. For each object in the hierarchy, ftw() shall call the function pointed to by fn, passing it a pointer to a null-terminated character string containing the name of the object, a pointer to a stat structure containing information about the object, and an integer.Possible values of the integer are: FTW_D For a directory. FTW_DNR For a directory that cannot be read. FTW_F For a file. FTW_SL For a symbolic link (but see also FTW_NS below). FTW_NS For an object other than a symbolic link on which stat() could not successfully be executed. If the object is a symbolic link and stat() failed, it is unspecified whether ftw() passes FTW_SL or FTW_NS to the user-supplied function.

The argument nfds should be in the range [1, {OPEN_MAX}].

Errors: [EACCES] Search permission is denied for any component of path or read permission is denied for path. [ELOOP] A loop exists in symbolic links encountered during resolution of the path argument. [ENAMETOOLONG] The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}. [ENOENT] A component of path does not name an existing file or path is an empty string. [ENOTDIR] A component of path is not a directory. [EOVERFLOW] A field in the stat structure cannot be represented correctly in the current programming environment for one or more files found in the file hierarchy.

Examples:
/*  Detailed description:  Sample usage of ftw system call
  Preconditions:  Function fn with the specified prototype should be defined and
  should have atleast two objects in the current working directory. 
 */
#include <ftw.h>
#include <stdlib.h>
#include <stdio.h>

if (ftw(".", fn, 2) != 0) {
    perror("ftw"); exit(2);
}
else
{
	printf("ftw call succeded");
}
Output
ftw call succeded

See also: stat()

Return Value
If the tree is exhausted, ftw() shall return 0. If the function pointed to by fn returns a non-zero value, ftw() shall stop its tree traversal and return whatever value was returned by the function pointed to by fn. If ftw() detects an error, it shall return -1 and set errno to indicate the error.
Capability
DeferredRFs::Entry(const TDesC16&, TEntry&)