blob: 9afd47b46f07c77ccb0a0b20a9594b3c06e6d2f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#include "errno.h" // for EISDIR, errno
#include <fcntl.h> // for AT_FDCWD, AT_REMOVEDIR
#include <stdio.h> // for remove
#include <syscall.h> // for __syscall_3, syscall
int remove(const char *path)
{
if (syscall(unlinkat, AT_FDCWD, path, 0) < 0) {
if (errno == EISDIR) {
return syscall(unlinkat, AT_FDCWD, path, AT_REMOVEDIR);
}
return -1;
}
return 0;
}
|