diff options
Diffstat (limited to 'src/extlib.c')
-rw-r--r-- | src/extlib.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/extlib.c b/src/extlib.c index 151a74f..13d7f50 100644 --- a/src/extlib.c +++ b/src/extlib.c @@ -17,12 +17,17 @@ * SPDX-License-Identifier: LGPL-3.0-only */ -#include "extlib.h" +#define _XOPEN_SOURCE 500 +#define USE_SECURE_MEM +#include <ftw.h> + +#include "extlib.h" #include <stdlib.h> #include <stdio.h> #include <string.h> + #undef free #undef malloc @@ -68,3 +73,22 @@ fcopy(FILE *f1, FILE *f2) fflush (f2); } } + +int +rmfile(const char *fpath, + const struct stat *sb, + int typeflag, + struct FTW *ftwbuf) +{ + int err = remove (fpath); + if (err < 0) return err; + return 0; +} + +int +rrmdir(char *pathname) +{ + int err = nftw (pathname, rmfile, 10, FTW_DEPTH|FTW_MOUNT|FTW_PHYS); + if (err < 0) return err; + return 0; +} |