From 90ed80e67073551a6016a57cbfb8d9804446e173 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 11 Aug 2014 01:39:00 +0000 Subject: Provide a fallback version of fts(3) for systems lacking it. I chose the OpenBSD version because it apparently contains various bugfixes that never made it into libnbcompat. To reduce size and complexity, i stripped out the features we don't need. --- test-fts.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test-fts.c (limited to 'test-fts.c') diff --git a/test-fts.c b/test-fts.c new file mode 100644 index 00000000..5c6fc2d0 --- /dev/null +++ b/test-fts.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include + +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(NULL) != 0) { + perror("fts_close"); + return(1); + } + + return(0); +} -- cgit v1.2.3