While traversing a directory using nftw like so,
nftw((argc < 2) ? "." : argv[1], rm, 20, FTW_DEPTH|FTW_PHYS)
nftw is passing a value of 5 to the rm function's tflag parameter when it encounters a directory. The ftw.h header only specifies an enum with 4 values (0-3) for the tflag parameter, of which FTW_D or 1 is the appropriate value for a directory. The fpath value appears to be correct in all instances.
So my question is this. Why is it passing 5 and not 1 for the tflag, and what does 5 mean for the tflag?
EDIT:
The value was in fact FTW_DP (Directory, all subdirs have been visited) which was defined below in an environment dependent portion which I failed to notice.
The POSIX specification of
nftw()says that the flag argument to yourrmfunction shall be one of:Since you don't identify your system and the standard doesn't define what number shall be associated with the flag argument to the called function, no-one can identify what the
5means on your system. However, there are enough options that5doesn't seem implausible as a value.On Mac OS X (10.9.5), the value
5would beFTW_SL. On another system, based on OSF, jedwards notes in a comment that the value5is forFTW_DP, thus fully justifying my observation that the flag represented by5is system-dependent.