xref: /netbsd/external/bsd/mdocml/dist/test-fts.c (revision 47a17e0d)
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <fts.h>
4 #include <stdio.h>
5 
6 int
7 main(void)
8 {
9 	const char	*argv[2];
10 	FTS		*ftsp;
11 	FTSENT		*entry;
12 
13 	argv[0] = ".";
14 	argv[1] = (char *)NULL;
15 
16 	ftsp = fts_open((char * const *)argv,
17 	    FTS_PHYSICAL | FTS_NOCHDIR, NULL);
18 
19 	if (ftsp == NULL) {
20 		perror("fts_open");
21 		return 1;
22 	}
23 
24 	entry = fts_read(ftsp);
25 
26 	if (entry == NULL) {
27 		perror("fts_read");
28 		return 1;
29 	}
30 
31 	if (fts_set(ftsp, entry, FTS_SKIP) != 0) {
32 		perror("fts_set");
33 		return 1;
34 	}
35 
36 	if (fts_close(ftsp) != 0) {
37 		perror("fts_close");
38 		return 1;
39 	}
40 
41 	return 0;
42 }
43