Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <ftw.h>
Link against: libc.lib
This item is not part of the S60 5th Edition SDK

FTW_F

Interface status: externallyDefinedApi

FTW_F 0

Description

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

[Top]


FTW_D

Interface status: externallyDefinedApi

FTW_D 1

Description

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

[Top]


FTW_DNR

Interface status: externallyDefinedApi

FTW_DNR 2

Description

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.

[Top]


FTW_DP

Interface status: externallyDefinedApi

FTW_DP 3

Description

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.

[Top]


FTW_NS

Interface status: externallyDefinedApi

FTW_NS 4

Description

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.

[Top]


FTW_SL

Interface status: externallyDefinedApi

FTW_SL 5

Description

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

[Top]


FTW_SLN

Interface status: externallyDefinedApi

FTW_SLN 6

Description

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.

[Top]


FTW_PHYS

FTW_PHYS 0x01

Description

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

[Top]


FTW_MOUNT

FTW_MOUNT 0x02

Description

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

[Top]


FTW_DEPTH

FTW_DEPTH 0x04

Description

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

[Top]


FTW_CHDIR

FTW_CHDIR 0x08

Description

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

[Top]


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

Interface status: externallyDefinedApi

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

Description

The ftw(const char *,int(*)(const char *, const struct stat *, int),int)ftw(const char *,int(*)(const char *, const struct stat *, int),int) function shall recursively descend the directory hierarchy rooted in path. For each object in the hierarchy, ftw(const char *,int(*)(const char *, const struct stat *, int),int)ftw(const char *,int(*)(const char *, const struct stat *, int),int) 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(const char *,struct stat *)stat(const char *,struct stat *) could not successfully be executed. If the object is a symbolic link and stat(const char *,struct stat *)stat(const char *,struct stat *) failed, it is unspecified whether ftw(const char *,int(*)(const char *, const struct stat *, int),int)ftw(const char *,int(*)(const char *, const struct stat *, int),int) 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. 
 */
# 54 "d:/EPOC/release/9.4/common/generic/openenv/core/include/ftw.dosc" 2
# 55 "d:/EPOC/release/9.4/common/generic/openenv/core/include/ftw.dosc" 2
# 56 "d:/EPOC/release/9.4/common/generic/openenv/core/include/ftw.dosc" 2

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

Output

ftw call succeded

Parameters

const char *

int(*)(const char *, const struct statstat *, int)

int

Return value

int

If the tree is exhausted, ftw(const char *,int(*)(const char *, const struct stat *, int),int)ftw(const char *,int(*)(const char *, const struct stat *, int),int) shall return 0. If the function pointed to by fn returns a non-zero value, ftw(const char *,int(*)(const char *, const struct stat *, int),int)ftw(const char *,int(*)(const char *, const struct stat *, int),int) shall stop its tree traversal and return whatever value was returned by the function pointed to by fn. If ftw(const char *,int(*)(const char *, const struct stat *, int),int)ftw(const char *,int(*)(const char *, const struct stat *, int),int) detects an error, it shall return -1 and set errno to indicate the error.

See also: