; * src/w32.c (sys_open): Set errno to EISDIR if opening a directory.
This commit is contained in:
parent
8f618711d1
commit
4e836407ce
1 changed files with 16 additions and 0 deletions
16
src/w32.c
16
src/w32.c
|
@ -4652,6 +4652,14 @@ sys_open (const char * path, int oflag, int mode)
|
|||
res = _wopen (mpath_w, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode);
|
||||
if (res < 0)
|
||||
res = _wopen (mpath_w, oflag | _O_NOINHERIT, mode);
|
||||
if (res < 0 && errno == EACCES)
|
||||
{
|
||||
DWORD attributes = GetFileAttributesW (mpath_w);
|
||||
|
||||
if (attributes != INVALID_FILE_ATTRIBUTES
|
||||
&& (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||
errno = EISDIR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4662,6 +4670,14 @@ sys_open (const char * path, int oflag, int mode)
|
|||
res = _open (mpath_a, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode);
|
||||
if (res < 0)
|
||||
res = _open (mpath_a, oflag | _O_NOINHERIT, mode);
|
||||
if (res < 0 && errno == EACCES)
|
||||
{
|
||||
DWORD attributes = GetFileAttributesA (mpath_a);
|
||||
|
||||
if (attributes != INVALID_FILE_ATTRIBUTES
|
||||
&& (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||
errno = EISDIR;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
Loading…
Add table
Reference in a new issue