EISDIR EACCES and open in grep

Mark Blackburn marklist@rivendell.fangorn.ca
Wed May 8 15:07:00 GMT 2002


I thought I'd throw in a suggestion for my problem with getting open to
return EISDIR. It seems that the win32 call CreateFile doesn't
distinguish between an access error and an error because you were
trying to open a directory as a file. Please take this with a grain of
salt since I'm a total cygwin.dll newbie (haven't compiled cygwin yet...)
so this may be totally way off base.

--- fhandler.cc.bak     Tue Feb 19 22:25:00 2002
+++ fhandler.cc Wed May  8 17:49:26 2002
@@ -406,8 +406,19 @@
 
   if (x == INVALID_HANDLE_VALUE)
     {
+      WIN32_FIND_DATA find_file_data;
       if (GetLastError () == ERROR_INVALID_HANDLE)
-       set_errno (ENOENT);
+        {
+         if (INVALID_HANDLE_VALUE != FindFirstFile(get_win32_name (),
+                                                    &find_file_data))
+           {
+             if (FILE_ATTRIBUTE_DIRECTORY == 
+                  find_file_data.dwFileAttributes)
+               set_errno (EISDIR);
+           }
+          else
+           set_errno (ENOENT);
+        }
       else
        __seterrno ();
       goto done;



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list