delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/05/08/17:57:49

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Wed, 8 May 2002 17:57:28 -0400 (EDT)
From: Mark Blackburn <marklist AT rivendell DOT fangorn DOT ca>
To: cygwin AT cygwin DOT com
Subject: RE: EISDIR EACCES and open in grep
Message-ID: <Pine.LNX.3.96.1020508174554.24906A-100000@rivendell.fangorn.ca>
MIME-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019