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
{
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;