ftw.h(0P)

πŸ¦‹ ftw.h β€” file tree traversal πŸ¦‹

okay so bestie, vibe check first πŸ’… this page is ftw.h(0P), and it comes to you straight from the POSIX Programmer's Manual ✨. two things you gotta know before we go any further though, fr fr:

  • the Linux implementation of this interface may differ β€” so if you're on Linux, go consult the corresponding Linux manual page for the actual tea on Linux behavior
  • or, honestly? the interface may not be implemented on Linux at all πŸ’€

iykyk. now let's get into it 🫢


✨ SYNOPSIS ✨

#include <ftw.h>

πŸ’– DESCRIPTION πŸ’–

first up, the <ftw.h> header shall define the FTW structure, and that struct has to include at least these members, no cap:

int  base
int  level

next, the <ftw.h> header shall define the following symbolic constants, and they're for use as values of the third argument to the application-supplied function that gets passed as the second argument to ftw() and nftw() πŸ‘‘

  • FTW_F β€” non-directory file πŸ“
  • FTW_D β€” directory 🌸
  • FTW_DNR β€” directory without read permission πŸ™ˆ
  • FTW_DP β€” directory with subdirectories visited πŸ‘‘
  • FTW_NS β€” unknown type; stat() failed πŸ’€
  • FTW_SL β€” symbolic link πŸ¦‹
  • FTW_SLN β€” symbolic link that names a nonexistent file 😭

and then the <ftw.h> header shall also define these next symbolic constants, for use as values of the fourth argument to nftw():

  • FTW_PHYS β€” physical walk, does not follow symbolic links. Otherwise, nftw() follows links but does not walk down any path that crosses itself. the way that's giving "look but don't touch" 🫢
  • FTW_MOUNT β€” the walk does not cross a mount point 🚧 (okay no, not that emoji β€” 🧚)
  • FTW_DEPTH β€” all subdirectories are visited before the directory itself 🌈
  • FTW_CHDIR β€” the walk changes to each directory before reading it πŸ’œ

now the functions. the following shall be declared as functions, and they may also be defined as macros β€” either way, function prototypes shall be provided:

int ftw(const char *, int (*)(const char *, const struct stat *,
    int), int);
int nftw(const char *, int (*)(const char *, const struct stat *,
    int, struct FTW *), int, int);

the <ftw.h> header shall define the stat structure and the symbolic names for st_mode and the file type test macros, exactly as described in <sys/stat.h> ⭐

also, just so you're not surprised: inclusion of the <ftw.h> header may also make visible all symbols from <sys/stat.h> πŸ‘€

and finally β€” the following sections are informative. that's the standard way of saying "these are the vibes, not the requirements" πŸ’…


πŸŽ€ APPLICATION USAGE πŸŽ€

None. literally nothing. a beautiful little void 🫢


🧚 RATIONALE 🧚

None. empty. iconic, honestly.


⭐ FUTURE DIRECTIONS ⭐

None. the future is wide open, bestie 🌈


πŸ”₯ SEE ALSO πŸ”₯

  • <sys_stat.h>
  • The System Interfaces volume of POSIX.1‐2017, ftw(), nftw()

okay this part is the legal bit, so we're being respectful and keeping every word πŸ’–

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie πŸ’– brought to you by IEEE/The Open Group, dated 2017, filed under ftw.h(0P). go traverse some file trees, you absolute main character πŸ‘‘βœ¨
πŸ“¦ where this page comes from