summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/remove.c
diff options
context:
space:
mode:
authorKacper <kacper@mail.openlinux.dev>2025-12-07 20:10:31 +0100
committerKacper <kacper@mail.openlinux.dev>2025-12-07 20:10:31 +0100
commitfc00c656c96528112d05cf0edf8631bd5eaea446 (patch)
treea6e0e6c588191a8bd1c64afc3b7a258e3e66c236 /lib/libc/stdio/remove.c
Add build system scaffolding and libc headers
Diffstat (limited to 'lib/libc/stdio/remove.c')
-rw-r--r--lib/libc/stdio/remove.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/libc/stdio/remove.c b/lib/libc/stdio/remove.c
new file mode 100644
index 00000000..9aec52e9
--- /dev/null
+++ b/lib/libc/stdio/remove.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <syscall.h>
+
+int remove(const char *path)
+{
+ if (syscall(unlinkat, AT_FDCWD, path, 0) < 0) {
+ if (errno == EISDIR) {
+ return syscall(unlinkat, AT_FDCWD, path, AT_REMOVEDIR);
+ } else {
+ return -1;
+ }
+ }
+
+ return 0;
+}