mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 22:38:30 +00:00
Fix remove() directory on Windows
This commit is contained in:
parent
e18fe1e112
commit
18964e5d76
3 changed files with 18 additions and 6 deletions
|
@ -53,12 +53,13 @@ int unlinkat(int dirfd, const char *path, int flags) {
|
|||
|
||||
// POSIX.1 says unlink(directory) raises EPERM but on Linux
|
||||
// it always raises EISDIR, which is so much less ambiguous
|
||||
if (!IsLinux() && rc == -1 && !flags && errno == EPERM) {
|
||||
int e = errno;
|
||||
if (!IsLinux() && rc == -1 && !flags && (e == EPERM || e == EACCES)) {
|
||||
struct stat st;
|
||||
if (!fstatat(dirfd, path, &st, 0) && S_ISDIR(st.st_mode)) {
|
||||
errno = EISDIR;
|
||||
} else {
|
||||
errno = EPERM;
|
||||
errno = e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue