diff options
-rw-r--r-- | src/ftw/__ftw.c | 12 | ||||
-rw-r--r-- | src/ftw/_ftw.h | 8 | ||||
-rw-r--r-- | src/ftw/ftw.c | 3 | ||||
-rw-r--r-- | src/ftw/nftw.c | 2 |
4 files changed, 23 insertions, 2 deletions
diff --git a/src/ftw/__ftw.c b/src/ftw/__ftw.c new file mode 100644 index 00000000..2acee0cb --- /dev/null +++ b/src/ftw/__ftw.c @@ -0,0 +1,12 @@ +#include "_ftw.h" + +int __ftw(const char *path, int (*fn)(), int fd_limit, int flags) +{ + struct FTW ft; + struct stat st; + int type = 0; + + int ret = (flags == __FTW_OLD) ? fn(path, &st, type) : fn(path, &st, type, &ft); + + return ret; +} diff --git a/src/ftw/_ftw.h b/src/ftw/_ftw.h new file mode 100644 index 00000000..2225061e --- /dev/null +++ b/src/ftw/_ftw.h @@ -0,0 +1,8 @@ +#ifndef ___FTW_H__ +#define ___FTW_H__ + +#define __FTW_OLD (-1) + +int __ftw(const char *path, int (*fn)(), int fd_limit, int flags); + +#endif diff --git a/src/ftw/ftw.c b/src/ftw/ftw.c index 8bac503e..f500615e 100644 --- a/src/ftw/ftw.c +++ b/src/ftw/ftw.c @@ -1,9 +1,10 @@ #include <ftw.h> #include <sys/stat.h> +#include "_ftw.h" int ftw(const char * path, int (*fn) (const char *, const struct stat * ptr, int flag), int ndirs) { - return -1; + return __ftw(path, fn, ndirs, __FTW_OLD); } /* diff --git a/src/ftw/nftw.c b/src/ftw/nftw.c index 8966953c..7dd80dd6 100644 --- a/src/ftw/nftw.c +++ b/src/ftw/nftw.c @@ -2,7 +2,7 @@ int nftw(const char * path, int (*fn) (const char *, const struct stat *, int, struct FTW *), int fd_limit, int flags) { - return 0; + return __ftw(path, fn, fd_limit, flags); } /* |