Tim Rühsen wrote:

Built on MinGW / Win32 the same open sets errno to EACCES.


We currently use a work-around like
+       int rc = open(pathname, flags, mode);
+#ifdef _WIN32
+       if (rc < 0 && errno == EACCES) {
+               DWORD attrs = GetFileAttributes(pathname);
+               if (attrs & FILE_ATTRIBUTE_DIRECTORY)
+                       errno = EISDIR;
+       }
+#endif

MSDN says:
  If the function fails, the return value is INVALID_FILE_ATTRIBUTES.

which is ((DWORD)-1). So the test should better be:

  if (attr != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
    errno = EISDIR;

--
--gv

Reply via email to