summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/remove.c
blob: 9aec52e938dc972b6c2d60651bd262b86e012193 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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;
}