aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test-fts.c
blob: dbee52926d4a4c0176e01a12eed5158dbd763186 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <sys/types.h>
#include <sys/stat.h>
#include <fts.h>
#include <stdio.h>

int
main(void)
{
	const char	*argv[2];
	FTS		*ftsp;
	FTSENT		*entry;

	argv[0] = ".";
	argv[1] = (char *)NULL;

	ftsp = fts_open((char * const *)argv,
	    FTS_PHYSICAL | FTS_NOCHDIR, NULL);

	if (ftsp == NULL) {
		perror("fts_open");
		return 1;
	}

	entry = fts_read(ftsp);

	if (entry == NULL) {
		perror("fts_read");
		return 1;
	}

	if (fts_set(ftsp, entry, FTS_SKIP) != 0) {
		perror("fts_set");
		return 1;
	}

	if (fts_close(ftsp) != 0) {
		perror("fts_close");
		return 1;
	}

	return 0;
}