From: Eric S. Raymond Date: Thu, 18 Sep 2003 19:22:38 +0000 (+0000) Subject: FreeBSD patches. X-Git-Tag: 2.1~14 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=9c4581babf8ce11d62b93abb62a371661d8c63c4;p=comparator.git FreeBSD patches. --- 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);