0

ALL,

According to this, ntfw is obsolete in POSIX.1-2008.

Is there a replacement of this function? Or I should use something else across the board?

TIA!

Igor
  • 5,620
  • 11
  • 51
  • 103
  • 2
    I think you've misread the manpage. *ftw()* is [obsolescent per POSIX](https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftw.html#tag_16_180_07), with *ntfw()* as its recommended successor. – pilcrow Sep 12 '19 at 15:20
  • @pilcrow, that's the problem - the link I referenced does not give the replacement there. It just states `POSIX.1-2008 marks ftw() as obsolete`. So basically I should use nftw() everywhere, right? – Igor Sep 12 '19 at 15:24

1 Answers1

1

From the link you cited:

POSIX.1-2001, SVr4, SUSv1. POSIX.1-2008 marks ftw() as obsolete. ...

On some systems ftw() will never use FTW_SL, on other systems FTW_SL occurs only for symbolic links that do not point to an existing file, and again on other systems ftw() will use FTW_SL for each symbolic link. For predictable control, use nftw().

My interpretation is that ftw was obsoleted in favor of nftw. So use that.

Personally, I would just implement my own. Every intro level CS textbook I've ever read covers filesystem traversal. I would use a fifo queue of dir handles and iterative breadth-first loop to avoid unnecessary function call overhead, both in the traversal and in the per-file hook (implemented as a function pointer in ftw).

Community
  • 1
  • 1
memtha
  • 797
  • 5
  • 24