Results 1 to 1 of 1
I am trying to write a program to walk the directory tree (millions of files and directories) and exclude any directory that is named ".snapshot". However, whenever a ".snapshot" directory ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-24-2011 #1
- Join Date
- Oct 2011
Can't get FTW_SKIP_SUBTREE to work
I am trying to write a program to walk the directory tree (millions of files and directories) and exclude any directory that is named ".snapshot".
However, whenever a ".snapshot" directory is encountered, nftw stops instead of continuing to the next directory. Any suggestions would be appreciated.
I am running "Red Hat Enterprise Linux Server release 6.1 (Santiago)".
I am using gcc "gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC)"
My code is as follows:
#define __USE_XOPEN_EXTENDED 1
#define _GNU_SOURCE 1
#define __USE_GNU 1
chuid(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftwbuf)
char *fname = basename(fpath);
printf("fname = %s; fpath = %s; tflag = %d\n", fname, fpath, tflag);
if ( (strcmp(fname, ".snapshot")) == 0 )
return FTW_CONTINUE; /* To tell nftw() to continue */
int flags = 0;
flags |= FTW_PHYS; /* do depth first traversal and don't follow sym links */
/* walk the directory tree */
nftw("testdir", chuid, 20, flags);