1 #define _XOPEN_SOURCE 500
12 static int process_one_entry(const char *fpath
, const struct stat
*sb
,
13 int typeflag
, struct FTW
*ftwbuf
)
17 const char *rel_path
= fpath
+ftwbuf
->base
;
19 printf("Processing %s in working dir %s\n",
20 rel_path
, get_current_dir_name());
21 if (stat(rel_path
, &buf
) < 0) {
22 perror("Oops...relative path does not exist in current directory");
30 char *path
= "/tmp/stest_dir";
31 char *subpath
= "/tmp/stest_dir/d1";
32 char *filepath
= "/tmp/stest_dir/f1";
33 char *filesubpath
= "/tmp/stest_dir/d1/f2";
35 if ((mkdir(path
, 0700)) < 0)
36 perror("Creating path");
37 if ((mkdir(subpath
, 0700)) < 0)
38 perror("Creating subpath");
39 if ((open(filepath
, O_CREAT
)) < 0)
40 perror("Opening filepath");
41 if ((open(filesubpath
, O_CREAT
)) < 0)
42 perror("Opening filesubpath");
44 if (nftw(path
, process_one_entry
, 100, (FTW_CHDIR
|FTW_DEPTH
|FTW_PHYS
)) < 0)
56 #define TEST_FUNCTION do_test ()
57 #include "../test-skeleton.c"