148352Scael.\" Copyright (c) 1989, 1991 The Regents of the University of California. 239801Sbostic.\" All rights reserved. 339801Sbostic.\" 443571Strent.\" %sccs.include.redist.man% 539801Sbostic.\" 6*50943Sbostic.\" @(#)fts.3 5.12 (Berkeley) 08/30/91 739801Sbostic.\" 848352Scael.Dd 948352Scael.Dt FTS 3 1048352Scael.Os 1148352Scael.Sh NAME 1248352Scael.Nm fts 1348352Scael.Nd traverse a file hierarchy 1448352Scael.Sh SYNOPSIS 1548352Scael.Fd #include <sys/types.h> 1648352Scael.Fd #include <sys/stat.h> 1748352Scael.Fd #include <fts.h> 1848352Scael.Ft FTS * 1948352Scael.Fn fts_open "char * const *path_argv" "int options" "int *compar(const FTSENT *, const FTSENT *)" 2048352Scael.Ft FTSENT * 2148352Scael.Fn fts_read "FTS *ftsp" 2248352Scael.Ft FTSENT * 2348352Scael.Fn fts_children "FTS *ftsp" 2448352Scael.Ft int 2548352Scael.Fn fts_set "FTS ftsp" "FTSENT *f" "int options" 2648352Scael.Ft int 2748352Scael.Fn fts_close "FTS *ftsp" 2848352Scael.Sh DESCRIPTION 2939801SbosticThe 3048352Scael.Nm fts 3148352Scaelfunctions are provided for traversing 3248352Scael.Tn UNIX 3348352Scaelfile hierarchies. 3448352Scael.Pp 3547194SbosticThe simple overview is that the 3648352Scael.Fn fts_open 3747194Sbosticfunction returns a ``handle'' on a file hierarchy, which is supplied to 3847194Sbosticthe other 3948352Scael.Nm fts 4045617Sbosticfunctions to determine which hierarchy they operate on. 4145617SbosticThe function 4248352Scael.Fn fts_read 4345617Sbosticreturns a pointer to a structure describing one of the files in the file 4445617Sbostichierarchy. 4545617SbosticThe function 4648352Scael.Fn fts_children 4745617Sbosticreturns a pointer to a linked list of structures, each of which describes 4845617Sbosticone of the files contained in a directory in the hierarchy. 4945617SbosticIn general, directories are visited two distinguishable times; in pre-order 5045617Sbostic(before any of their descendants are visited) and in post-order (after all 5145617Sbosticof their descendants have been visited). 5245617SbosticFiles are visited once. 5345617SbosticIt is possible to walk the hierarchy ``logically'' (ignoring symbolic links) 5445617Sbosticor physically (visiting symbolic links), order the walk of the hierarchy or 5545617Sbosticprune and/or re-visit portions of the hierarchy. 5648352Scael.Pp 5748352ScaelTwo structures are defined (and typedef'd) in the include file 5848352Scael.Aq Pa fts.h . 5948352ScaelThe first is 6048352Scael.Fa FTS , 6148352Scaelthe structure that represents the file hierarchy stream. 6248352ScaelThe second is 6348352Scael.Fa FTSENT , 6448352Scaelthe structure that represents a file in the file 6545617Sbostichierarchy. 6648352ScaelNormally, an 6748352Scael.Fa FTSENT 6848352Scaelstructure is returned for every file in the file 6945617Sbostichierarchy. 7048352ScaelIn this manual page, ``file'' and 7148352Scael.Dq Fa FTSENT No structure 7248352Scaelare generally 7345617Sbosticinterchangeable. 7448352ScaelThe 7548352Scael.Fa FTSENT 7648352Scaelstructure contains at least the following fields, which are 7745617Sbosticdescribed in greater detail below: 7850725Scael.Bd -literal 7945617Sbostictypedef struct _ftsent { 8048352Scael u_short fts_info; /* flags for FTSENT structure */ 8148352Scael char *fts_accpath; /* access path */ 8245617Sbostic char *fts_path; /* root path */ 8348352Scael short fts_pathlen; /* strlen(fts_path) */ 8442273Sbostic char *fts_name; /* file name */ 8548352Scael short fts_namelen; /* strlen(fts_name) */ 8648352Scael short fts_level; /* depth (\-1 to N) */ 8748352Scael long fts_number; /* local numeric value */ 8845617Sbostic void *fts_pointer; /* local address value */ 8948352Scael struct ftsent *fts_parent; /* parent directory */ 9048352Scael struct ftsent *fts_link; /* cycle or next file structure */ 9148352Scael struct stat fts_statb; /* stat(2) information */ 9239801Sbostic} FTSENT; 9348352Scael.Ed 9448352Scael.Pp 9545617SbosticThese fields are defined as follows: 9648352Scael.Bl -tag -width "fts_namelen" 9748352Scael.It Fa fts_info 9848352ScaelOne of the following flags describing the returned 9948352Scael.Fa FTSENT 10048352Scaelstructure and 10145617Sbosticthe file it represents. 10248352ScaelWith the exception of directories without errors 10348352Scael.Pq Dv FTS_D , 10448352Scaelall of these 10545617Sbosticentries are terminal, that is, they will not be revisited, nor will any 10645617Sbosticof their descendants be visited. 10748352Scael.Bl -tag -width FTS_DEFAULT 10848352Scael.It Dv FTS_D 10939801SbosticA directory being visited in pre-order. 11048352Scael.It Dv FTS_DC 11145617SbosticA directory that causes a cycle in the tree. 11245617Sbostic(The 11348352Scael.Fa fts_link 11448352Scaelfield of the 11548352Scael.Fa FTSENT 11648352Scaelstructure will be filled in as well.) 11748352Scael.It Dv FTS_DEFAULT 11848352ScaelAny 11948352Scael.Fa FTSENT 12048352Scaelstructure that represents a file type not explicitly described 12145617Sbosticby one of the other 12248352Scael.Fa fts_info 12345617Sbosticvalues. 12448352Scael.It Dv FTS_DNR 12545617SbosticA directory which cannot be read. 12647194SbosticAn error return; the external variable 12748352Scael.Va errno 12847194Sbosticwill be set to indicate the error. 12948352Scael.It Dv FTS_DOT 13048352ScaelA file named 13148352Scael.Ql \&. 13248352Scaelor 13348352Scael.Ql .. 13448352Scaelwhich was not specified as a file name to 13548352Scael.Fn fts_open 13648352Scael(see 13748352Scael.Dv FTS_SEEDOT ) . 13848352Scael.It Dv FTS_DP 13945617SbosticA directory being visited in post-order. 14048352ScaelThe contents of the 14148352Scael.Fa FTSENT 14248352Scaelstructure will be unchanged from when 14345617Sbosticit was returned in pre-order, i.e. with the 14448352Scael.Fa fts_info 14548352Scaelfield set to 14648352Scael.Dv FTS_D . 14748352Scael.It Dv FTS_ERR 14845617SbosticAn error return; the external variable 14948352Scael.Va errno 15045617Sbosticwill be set to indicate the error. 15148352Scael.It Dv FTS_F 15239801SbosticA regular file. 15348352Scael.It Dv FTS_NS 15445617SbosticA file for which no 15548352Scael.Xr stat 2 15647194Sbosticinformation was available. 15747194SbosticThe contents of the 15848352Scael.Fa fts_statb 15939801Sbosticfield are undefined. 16047194SbosticAn error return; the external variable 16148352Scael.Va errno 16247194Sbosticwill be set to indicate the error. 16348352Scael.It Dv FTS_NSOK 16447194SbosticA file for which no 16548352Scael.Xr stat 2 16647194Sbosticinformation was requested. 16747194SbosticThe contents of the 16848352Scael.Fa fts_statb 16947194Sbosticfield are undefined. 17048352Scael.It Dv FTS_SL 17139801SbosticA symbolic link. 17248352Scael.It Dv FTS_SLNONE 17339801SbosticA symbolic link with a non-existent target. 17447194SbosticThe contents of the 17548352Scael.Fa fts_statb 17647194Sbosticfield contain the file characteristic information for the symbolic link 17747194Sbosticitself. 17848352Scael.El 17948352Scael.It Fa fts_accpath 18047194SbosticA path for accessing the file from the current directory. 18148352Scael.It Fa fts_path 18245617SbosticThe path for the file relative to the root of the traversal. 18345617SbosticThis path contains the path specified to 18448352Scael.Fn fts_open 18545617Sbosticas a prefix. 18648352Scael.It Fa fts_pathlen 18745617SbosticThe length of the string referenced by 18848352Scael.Fa fts_path . 18948352Scael.It Fa fts_name 19045617SbosticThe name of the file. 19148352Scael.It Fa fts_namelen 19245617SbosticThe length of the string referenced by 19348352Scael.Fa fts_name . 19448352Scael.It Fa fts_level 19545617SbosticThe depth of the traversal, numbered from \-1 to N, where this file 19645617Sbosticwas found. 19748352ScaelThe 19848352Scael.Fa FTSENT 19948352Scaelstructure representing the parent of the starting point (or root) 20048352Scaelof the traversal is numbered \-1, and the 20148352Scael.Fa FTSENT 20248352Scaelstructure for the root 20345617Sbosticitself is numbered 0. 20448352Scael.It Fa fts_number 20545617SbosticThis field is provided for the use of the application program and is 20645617Sbosticnot modified by the 20748352Scael.Nm fts 20845617Sbosticfunctions. 20945617SbosticIt is initialized to 0. 21045617SbosticThe fields 21148352Scael.Fa fts_number 21245617Sbosticand 21348352Scael.Fa fts_pointer 21445617Sbosticoccupy the same physical location; using both may cause undefined results. 21548352Scael.It Fa fts_pointer 21645617SbosticThis field is provided for the use of the application program and is 21745617Sbosticnot modified by the 21848352Scael.Nm fts 21945617Sbosticfunctions. 22048352ScaelIt is initialized to 22148352Scael.Dv NULL . 22245617SbosticThe fields 22348352Scael.Fa fts_number 22445617Sbosticand 22548352Scael.Fa fts_pointer 22645617Sbosticoccupy the same physical location; using both may cause undefined results. 22748352Scael.It Fa fts_parent 22848352ScaelA pointer to the 22948352Scael.Fa FTSENT 23048352Scaelstructure referencing the file in the hierarchy 23145617Sbosticimmediately above the current file, i.e. the directory of which this 23245617Sbosticfile is a member. 23345617SbosticA parent structure for the initial entry point is provided as well, 23445617Sbostichowever, only the 23548352Scael.Fa fts_level , 23648352Scael.Fa fts_number 23745617Sbosticand 23848352Scael.Fa fts_pointer 23945617Sbosticfields are guaranteed to be initialized. 24048352Scael.It Fa fts_link 24145617SbosticThe 24248352Scael.Fa fts_link 24345617Sbosticfield has two separate uses. 24448352ScaelIf a directory causes a cycle in the hierarchy (see 24548352Scael.Dv FTS_DC ) , 24648352Scaeleither because 24745617Sbosticof a hard link between two directories, or a symbolic link pointing to a 24845617Sbosticdirectory, the 24948352Scael.Fa fts_link 25048352Scaelfield of the structure will point to the 25148352Scael.Fa FTSENT 25248352Scaelstructure in the hierarchy 25348352Scaelthat references the same file as the current 25448352Scael.Fa FTSENT 25548352Scaelstructure. 25645617SbosticAlso, upon return from the 25748352Scael.Fn fts_children 25845617Sbosticfunction, the 25948352Scael.Fa fts_link 26045617Sbosticfield points to the next structure in the linked list of directory members. 26145617SbosticOtherwise, the contents of the 26248352Scael.Fa fts_link 26345617Sbosticfield are undefined. 26448352Scael.It Fa fts_statb 26548352Scael.Xr Stat 2 26639801Sbosticinformation for the file. 26748352Scael.El 26848352Scael.Sh FTS_OPEN 26945617SbosticThe 27048352Scael.Fn fts_open 27145617Sbosticfunction takes a pointer to an array of character pointers naming one 27245617Sbosticor more paths which make up a logical file hierarchy to be traversed. 27348352ScaelThe array must be terminated by a 27448352Scael.Dv NULL 27548352Scaelpointer. 27648352Scael.Pp 27748352ScaelThere are 27848352Scaela number of options, at least one of which (either 27948352Scael.Dv FTS_LOGICAL 28048352Scaelor 28148352Scael.Dv FTS_PHYSICAL ) 28248352Scaelmust be specified. 28345617SbosticThe options are selected by 28448352Scael.Em or Ns 'ing 28545617Sbosticthe following values: 28648352Scael.Bl -tag -width "FTS_PHYSICAL" 28748352Scael.It Dv FTS_LOGICAL 28845617SbosticThis option causes the 28948352Scael.Nm fts 29048352Scaelroutines to return 29148352Scael.Fa FTSENT 29248352Scaelstructures for the targets of symbolic links 29345617Sbosticinstead of the symbolic links themselves. 29448352ScaelIf this option is set, the only symbolic links for which 29548352Scael.Fa FTSENT 29648352Scaelstructures 29745617Sbosticare returned to the application are those referencing non-existent files. 29848352ScaelEither 29948352Scael.Dv FTS_LOGICAL 30048352Scaelor 30148352Scael.Dv FTS_PHYSICAL 30248352Scael.Em must 30345617Sbosticbe provided to the 30448352Scael.Fn fts_open 30545617Sbosticfunction. 30648352Scael.It Dv FTS_NOCHDIR 30745617SbosticAs a performance optimization, the 30848352Scael.Nm fts 30945617Sbosticfunctions change directories as they walk the file hierarchy. 31045617SbosticThis has the side-effect that an application cannot rely on being 31145617Sbosticin any particular directory during the traversal. 31248352ScaelThe 31348352Scael.Dv FTS_NOCHDIR 31448352Scaeloption turns off this optimization, and the 31548352Scael.Nm fts 31645617Sbosticfunctions will not change the current directory. 31745617SbosticNote that applications should not themselves change their current directory 31848352Scaeland try to access files unless 31948352Scael.Dv FTS_NOCHDIR 32048352Scaelis specified and absolute 32145617Sbosticpathnames were provided as arguments to 32248352Scael.Fn fts_open . 32348352Scael.It Dv FTS_NOSTAT 32448352ScaelBy default, returned 32548352Scael.Fa FTSENT 32648352Scaelstructures contain file characteristic 32745617Sbosticinformation (the 32848352Scael.Fa statb 32945617Sbosticfield) for each file visited. 33045617SbosticThis option relaxes that requirement as a performance optimization, 33145617Sbosticallowing the 33248352Scael.Nm fts 33345617Sbosticfunctions to set the 33448352Scael.Fa fts_info 33548352Scaelfield to 33648352Scael.Dv FTS_NSOK 33748352Scaeland leave the contents of the 33848352Scael.Fa statb 33945617Sbosticfield undefined. 34048352Scael.It Dv FTS_PHYSICAL 34145617SbosticThis option causes the 34248352Scael.Nm fts 34348352Scaelroutines to return 34448352Scael.Fa FTSENT 34548352Scaelstructures for symbolic links themselves instead 34645617Sbosticof the target files they point to. 34748352ScaelIf this option is set, 34848352Scael.Fa FTSENT 34948352Scaelstructures for all symbolic links in the 35045617Sbostichierarchy are returned to the application. 35148352ScaelEither 35248352Scael.Dv FTS_LOGICAL 35348352Scaelor 35448352Scael.Dv FTS_PHYSICAL 35548352Scael.Em must 35645617Sbosticbe provided to the 35748352Scael.Fn fts_open 35845617Sbosticfunction. 35948352Scael.It Dv FTS_SEEDOT 36045617SbosticBy default, unless they are specified as path arguments to 36148352Scael.Fn fts_open , 36248352Scaelany files named 36348352Scael.Ql \&. 36448352Scaeland 36548352Scael.Ql .. 36648352Scaelencountered in the file hierarchy are 36745617Sbosticignored. 36845617SbosticThis option causes the 36948352Scael.Nm fts 37048352Scaelroutines to return 37148352Scael.Fa FTSENT 37248352Scaelstructures for them. 37348352Scael.It Dv FTS_XDEV 37445617SbosticThis option prevents 37548352Scael.Nm fts 37645617Sbosticfrom descending into directories that have a different device number 37745617Sbosticthan the file from which the descent began. 37848352Scael.El 37948352Scael.Pp 38045617SbosticThe argument 38148352Scael.Fn compar 38245617Sbosticspecifies a user-defined function which may be used to order the traversal 38345617Sbosticof the hierarchy. 38448352ScaelIt 38548352Scaeltakes two pointers to pointers to 38648352Scael.Fa FTSENT 38748352Scaelstructures as arguments and 38845617Sbosticshould return a negative value, zero, or a positive value to indicate 38945617Sbosticif the file referenced by its first argument comes before, in any order 39045617Sbosticwith respect to, or after, the file referenced by its second argument. 39139801SbosticThe 39248352Scael.Fa fts_accpath , 39348352Scael.Fa fts_path 39439801Sbosticand 39548352Scael.Fa fts_pathlen 39648352Scaelfields of the 39748352Scael.Fa FTSENT 39848352Scaelstructures may 39948352Scael.Em never 40045617Sbosticbe used in this comparison. 40147194SbosticIf the 40248352Scael.Fa fts_info 40348352Scaelfield is set to 40448352Scael.Dv FTS_NS 40548352Scaelor 40648352Scael.DV FTS_NSOK , 40748352Scaelthe 40848352Scael.Fa fts_stab 40945617Sbosticfield may not either. 41045617SbosticIf the 41148352Scael.Fn compar 41248352Scaelargument is 41348352Scael.Dv NULL , 41448352Scaelthe directory traversal order is unspecified except 41545617Sbosticfor the root paths which are traversed in the order listed in 41648352Scael.Fa path_argv . 41748352Scael.Sh FTS_READ 41839801SbosticThe 41948352Scael.Fn fts_read 42048352Scaelfunction returns a pointer to an 42148352Scael.Fa FTSENT 42248352Scaelstructure describing a file in 42345617Sbosticthe hierarchy. 42447194SbosticDirectories (that are readable and do not cause cycles) are visited at 42547194Sbosticleast twice, once in pre-order and once in post-order. 42645617SbosticAll other files are visited at least once. 42745617Sbostic(Hard links between directories that do not cause cycles or symbolic 42845617Sbosticlinks to symbolic links may cause files to be visited more than once, 42945617Sbosticor directories more than twice.) 43048352Scael.Pp 43139801SbosticIf all the members of the hierarchy have been returned, 43248352Scael.Fn fts_read 43348352Scaelreturns 43448352Scael.Dv NULL 43548352Scaeland sets the external variable 43648352Scael.Va errno 43739801Sbosticto 0. 43839801SbosticIf an error unrelated to a file in the hierarchy occurs, 43948352Scael.Fn fts_read 44048352Scaelreturns 44148352Scael.Dv NULL 44248352Scaeland sets 44348352Scael.Va errno 44445617Sbosticappropriately. 44548352ScaelIf an error related to a returned file occurs, a pointer to an 44648352Scael.Fa FTSENT 44745617Sbosticstructure is returned, and 44848352Scael.Va errno 44945617Sbosticmay or may not have been set (see 45048352Scael.Fa fts_info ) . 45148352Scael.Pp 45248352ScaelThe 45348352Scael.Fa FTSENT 45448352Scaelstructures returned by 45548352Scael.Fn fts_read 45645617Sbosticmay be overwritten after a call to 45748352Scael.Fn fts_close 45845617Sbosticon the same file hierarchy stream, or, after a call to 45948352Scael.Fn fts_read 46045617Sbosticon the same file hierarchy stream unless they represent a file of type 46145617Sbosticdirectory, in which case they will not be overwritten until after a call to 46248352Scael.Fn fts_read 46348352Scaelafter the 46448352Scael.Fa FTSENT 46548352Scaelstructure has been returned by the function 46648352Scael.Fn fts_read 46745617Sbosticin post-order. 46848352Scael.Sh FTS_CHILDREN 46945617SbosticThe 47048352Scael.Fn fts_children 47148352Scaelfunction returns a pointer to an 47248352Scael.Fa FTSENT 47348352Scaelstructure describing the first 47445617Sbosticentry in a linked list of the files in the directory represented by the 47548352Scael.Fa FTSENT 47648352Scaelstructure most recently returned by 47748352Scael.Fn fts_read . 47845617SbosticThe list is linked through the 47948352Scael.Fa fts_link 48048352Scaelfield of the 48148352Scael.Fa FTSENT 48248352Scaelstructure, and is ordered by the user-specified 48345617Sbosticcomparison function, if any. 48445617SbosticRepeated calls to 48548352Scael.Fn fts_children 48645617Sbosticwill recreate this linked list. 48748352Scael.Pp 48848352ScaelIf the 48948352Scael.Fa FTSENT 49048352Scaelstructure most recently returned by 49148352Scael.Fn fts_read 49245617Sbosticis not a directory being visited in pre-order, 49345617Sbosticor the directory does not contain any files, 49448352Scael.Fn fts_children 49548352Scaelreturns 49648352Scael.Dv NULL 49748352Scaeland sets 49848352Scael.Va errno 49945617Sbosticto zero. 50039801SbosticIf an error occurs, 50148352Scael.Fn fts_children 50248352Scaelreturns 50348352Scael.Dv NULL 50448352Scaeland sets 50548352Scael.Va errno 50645617Sbosticappropriately. 50748352Scael.Pp 50848352ScaelThe 50948352Scael.Fa FTSENT 51048352Scaelstructures returned by 51148352Scael.Fn fts_children 51239801Sbosticmay be overwritten after a call to 51348352Scael.Fn fts_close 51445617Sbosticon the same file hierarchy stream, or after a call to 51548352Scael.Fn fts_children 51639801Sbosticor 51748352Scael.Fn fts_read 51845617Sbosticon the same file hierarchy stream. 51948352Scael.Pp 52045617SbosticA single buffer is used for all of the paths of all of the files in the 52145617Sbosticfile hierarchy. 52245617SbosticTherefore, the 52348352Scael.Fa fts_path 52445617Sbosticand 52548352Scael.Fa fts_accpath 52648352Scaelfields are guaranteed to be 52748352Scael.Dv NULL Ns -terminated 52848352Scael.Em only 52945617Sbosticfor the file most recently returned by 53048352Scael.Fn fts_read . 53148352ScaelTo use these fields to reference any files represented by other 53248352Scael.Fa FTSENT 53345617Sbosticstructures will require that the path buffer be modified using the 53448352Scaelinformation contained in that 53548352Scael.Fa FTSENT 53648352Scaelstructure's 53748352Scael.Fa fts_pathlen 53845617Sbosticfield. 53945617SbosticAny such modifications should be undone before further calls to 54048352Scael.Fn fts_read 54145617Sbosticare attempted. 54245617SbosticThe 54348352Scael.Fa fts_name 54448352Scaelfield is always 54548352Scael.Dv NULL Ns -terminated. 54648352Scael.Sh FTS_SET 54745617SbosticThe function 54848352Scael.Fn fts_set 54939801Sbosticallows the user application to determine further processing for the 55039801Sbosticfile 55148352Scael.Fa f 55239801Sbosticof the stream 55348352Scael.Fa ftsp . 55448352ScaelThe 55548352Scael.Fn fts_set 55648352Scaelfunction 55748352Scaelreturns 0 on success, and \-1 if an error occurs. 55848352Scael.Em Option 55945617Sbosticmust be set to one of the following values: 56048352Scael.Bl -tag -width FTS_PHYSICAL 56148352Scael.It Dv FTS_AGAIN 56239801SbosticRe-visit the file; any file type may be re-visited. 56339801SbosticThe next call to 56448352Scael.Fn fts_read 56539801Sbosticwill return the referenced file. 56645617SbosticThe 56748352Scael.Fa fts_stat 56839801Sbosticand 56948352Scael.Fa fts_info 57039801Sbosticfields of the structure will be reinitialized at that time, 57145617Sbosticbut no other fields will have been changed. 57239801SbosticThis option is meaningful only for the most recently returned 57339801Sbosticfile from 57448352Scael.Fn fts_read . 57539801SbosticNormal use is for post-order directory visits, where it causes the 57639801Sbosticdirectory to be re-visited (in both pre and post-order) as well as all 57739801Sbosticof its descendants. 57848352Scael.It Dv FTS_FOLLOW 57939801SbosticThe referenced file must be a symbolic link. 58039801SbosticIf the referenced file is the one most recently returned by 58148352Scael.Fn fts_read , 58239801Sbosticthe next call to 58348352Scael.Fn fts_read 58439801Sbosticreturns the file with the 58548352Scael.Fa fts_info 58639801Sbosticand 58748352Scael.Fa fts_statb 58839801Sbosticfields reinitialized to reflect the target of the symbolic link instead 58939801Sbosticof the symbolic link itself. 59039801SbosticIf the file is one of those most recently returned by 59148352Scael.Fn fts_children , 59239801Sbosticthe 59348352Scael.Fa fts_info 59439801Sbosticand 59548352Scael.Fa fts_statb 59639801Sbosticfields of the structure, when returned by 59748352Scael.Fn fts_read , 59839801Sbosticwill reflect the target of the symbolic link instead of the symbolic link 59939801Sbosticitself. 60047194SbosticIn either case, if the target of the symbolic link does not exist the 60147194Sbosticfields of the returned structure will be unchanged and the 60248352Scael.Fa fts_info 60348352Scaelfield will be set to 60448352Scael.Dv FTS_SLNONE . 60548352Scael.Pp 60647194SbosticIf the target of the link is a directory, the pre-order return, followed 60747194Sbosticby the return of all of its descendants, followed by a post-order return, 60847194Sbosticis done. 60948352Scael.It Dv FTS_SKIP 61039801SbosticNo descendants of this file are visited. 61145617SbosticThe file may be one of those most recently returned by either 61248352Scael.Fn fts_children 61345617Sbosticor 61448352Scael.Fn fts_read . 61548352Scael.El 61648352Scael.Sh FTS_CLOSE 61745617SbosticThe 61848352Scael.Fn fts_close 61945617Sbosticfunction closes a file hierarchy stream 62048352Scael.Fa ftsp 62145617Sbosticand restores the current directory to the directory from which 62248352Scael.Fn fts_open 62345617Sbosticwas called to open 62448352Scael.Fa ftsp . 62548352ScaelThe 62648352Scael.Fn fts_close 62748352Scaelfunction 62848352Scaelreturns 0 on success, and \-1 if an error occurs. 62948352Scael.Sh ERRORS 63048352ScaelThe function 63148352Scael.Fn fts_open 63239801Sbosticmay fail and set errno for any of the errors specified for the library 63345661Sbosticfunctions 63448352Scael.Xr open 2 63545661Sbosticand 63648352Scael.Xr malloc 3 . 63748352Scael.Pp 63848352ScaelThe function 63948352Scael.Fn fts_close 64039801Sbosticmay fail and set errno for any of the errors specified for the library 64145661Sbosticfunctions 64248352Scael.Xr chdir 2 64345661Sbosticand 64448352Scael.Xr close 2 . 64548352Scael.Pp 64648352ScaelThe functions 647*50943Sbostic.Fn fts_read 64839801Sbosticand 64948352Scael.Fn fts_children 65039801Sbosticmay fail and set errno for any of the errors specified for the library 65145617Sbosticfunctions 65248352Scael.Xr chdir 2 , 65348352Scael.Xr malloc 3 , 65448352Scael.Xr opendir 3 , 65548352Scael.Xr readdir 3 65639801Sbosticand 65748352Scael.Xr stat 2 . 65848352Scael.Sh SEE ALSO 65948352Scael.Xr find 1 , 66048352Scael.Xr chdir 2 , 66148352Scael.Xr stat 2 , 66248352Scael.Xr qsort 3 66348352Scael.Sh STANDARDS 66439801SbosticThe 66548352Scael.Nm fts 66648352Scaelutility is expected to be a superset of the 66748352Scael.St -p1003.1-88 66847194Sbosticspecification. 669