From 9c4581babf8ce11d62b93abb62a371661d8c63c4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 18 Sep 2003 19:22:38 +0000 Subject: [PATCH] FreeBSD patches. --- shredtree.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/shredtree.c b/shredtree.c index ebe1c8e..dd0bb3f 100644 --- a/shredtree.c +++ b/shredtree.c @@ -3,7 +3,16 @@ #include #include #include -#include + +#if defined(__FreeBSD__) +# include +# include +# include +# define FTW_F 1 +#else +# include +#endif + #include #include #include @@ -281,10 +290,30 @@ char **sorted_file_list(const char *tree, int *fc) /* generate a sorted list of files under the given tree */ { char **place, **list; +#if defined(__FreeBSD__) + char *dirlist[2]; + FTS *ftsptr; + FTSENT *entry; +#endif /* make file list */ file_count = 0; +#if defined(__FreeBSD__) + dirlist[0]= tree; dirlist[1]= NULL; + ftsptr= fts_open(dirlist, FTS_LOGICAL, NULL); + + /* process each entry that is a file */ + while(1) { + entry= fts_read(ftsptr); + if (entry==NULL) break; + if (entry->fts_info==FTS_F) { + treewalker(entry->fts_accpath, entry->fts_statp, 1); + } + } + fts_close(ftsptr); +#else ftw(tree, treewalker, 16); +#endif /* now that we know the length, copy into an array */ list = place = (char **)calloc(sizeof(char *), file_count); -- 2.43.0