aboutsummaryrefslogtreecommitdiff
path: root/src/extlib.c
diff options
context:
space:
mode:
authoraxtloss <axtlos@getcryst.al>2024-07-08 13:03:03 +0200
committeraxtloss <axtlos@getcryst.al>2024-07-08 13:03:03 +0200
commit5a0598e0b8d42bc3800cf0d0a49572d13f7b0afa (patch)
tree996744adacd2ff590597aab9e92bea23f46db07e /src/extlib.c
parenta084dfa02d28a9372a7e406c9b101a43308a4937 (diff)
downloadextlib-5a0598e0b8d42bc3800cf0d0a49572d13f7b0afa.tar.gz
extlib-5a0598e0b8d42bc3800cf0d0a49572d13f7b0afa.tar.bz2
add new function rremove
Diffstat (limited to 'src/extlib.c')
-rw-r--r--src/extlib.c26
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;
+}