diff options
| author | Eli Zaretskii | 2024-05-29 17:56:18 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2024-05-29 17:56:18 +0300 |
| commit | 4e836407ce3a2140725c7ddc2cedc3478d34a479 (patch) | |
| tree | a8abbb7ede9d8de55f8889acd7e13993ba94892c /src | |
| parent | 8f618711d13fb82b10b67a12f47736e01ec4b92b (diff) | |
| download | emacs-4e836407ce3a2140725c7ddc2cedc3478d34a479.tar.gz emacs-4e836407ce3a2140725c7ddc2cedc3478d34a479.zip | |
; * src/w32.c (sys_open): Set errno to EISDIR if opening a directory.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 16 |
1 files changed, 16 insertions, 0 deletions
| @@ -4652,6 +4652,14 @@ sys_open (const char * path, int oflag, int mode) | |||
| 4652 | res = _wopen (mpath_w, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); | 4652 | res = _wopen (mpath_w, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); |
| 4653 | if (res < 0) | 4653 | if (res < 0) |
| 4654 | res = _wopen (mpath_w, oflag | _O_NOINHERIT, mode); | 4654 | res = _wopen (mpath_w, oflag | _O_NOINHERIT, mode); |
| 4655 | if (res < 0 && errno == EACCES) | ||
| 4656 | { | ||
| 4657 | DWORD attributes = GetFileAttributesW (mpath_w); | ||
| 4658 | |||
| 4659 | if (attributes != INVALID_FILE_ATTRIBUTES | ||
| 4660 | && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) | ||
| 4661 | errno = EISDIR; | ||
| 4662 | } | ||
| 4655 | } | 4663 | } |
| 4656 | else | 4664 | else |
| 4657 | { | 4665 | { |
| @@ -4662,6 +4670,14 @@ sys_open (const char * path, int oflag, int mode) | |||
| 4662 | res = _open (mpath_a, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); | 4670 | res = _open (mpath_a, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); |
| 4663 | if (res < 0) | 4671 | if (res < 0) |
| 4664 | res = _open (mpath_a, oflag | _O_NOINHERIT, mode); | 4672 | res = _open (mpath_a, oflag | _O_NOINHERIT, mode); |
| 4673 | if (res < 0 && errno == EACCES) | ||
| 4674 | { | ||
| 4675 | DWORD attributes = GetFileAttributesA (mpath_a); | ||
| 4676 | |||
| 4677 | if (attributes != INVALID_FILE_ATTRIBUTES | ||
| 4678 | && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) | ||
| 4679 | errno = EISDIR; | ||
| 4680 | } | ||
| 4665 | } | 4681 | } |
| 4666 | 4682 | ||
| 4667 | return res; | 4683 | return res; |