diff options
Diffstat (limited to 'lib/libc/stdio/remove.c')
| -rw-r--r-- | lib/libc/stdio/remove.c | 16 |
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; +} |
