diff options
author | axtloss <axtlos@getcryst.al> | 2024-07-08 13:03:03 +0200 |
---|---|---|
committer | axtloss <axtlos@getcryst.al> | 2024-07-08 13:03:03 +0200 |
commit | 5a0598e0b8d42bc3800cf0d0a49572d13f7b0afa (patch) | |
tree | 996744adacd2ff590597aab9e92bea23f46db07e /src/extlib.c | |
parent | a084dfa02d28a9372a7e406c9b101a43308a4937 (diff) | |
download | extlib-5a0598e0b8d42bc3800cf0d0a49572d13f7b0afa.tar.gz extlib-5a0598e0b8d42bc3800cf0d0a49572d13f7b0afa.tar.bz2 |
add new function rremove
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; +} |