In C, is there a way to specify the maximum depth from the base directory that nftw will search? For example, say the directory dir that I want to search has a sub-subdirectory, but I only want nftw to search through subdir and not sub-subdir, or anything below that.
dir
\_ subdir
|__ file1
|__ file2
\_ sub-subdir
|__ file1
|__ file2
\_ file3
According to the manual page (http://man7.org/linux/man-pages/man3/nftw.3.html) you can stop to go in subdirectories from inside the function argument.
From the example reported in the manual with a limitation to 2 levels in subdirs the source code is: