2003-03-03 Dick Porter <dick@ximian.com>
authorDick Porter <dick@acm.org>
Mon, 3 Mar 2003 13:23:20 +0000 (13:23 -0000)
committerDick Porter <dick@acm.org>
Mon, 3 Mar 2003 13:23:20 +0000 (13:23 -0000)
* io.c (CreateFile): Try opening directories readonly, so that
timestamps can be adjusted.  Patch by Elan Feingold
<efeingold@mn.rr.com>.

svn path=/trunk/mono/; revision=12121

mono/io-layer/ChangeLog
mono/io-layer/io.c

index bf88e25e326ac6633d056db1936f9234f316638d..213734044e6f04a2468aafcabb5cd0e28457c6d9 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-03  Dick Porter  <dick@ximian.com>
+
+       * io.c (CreateFile): Try opening directories readonly, so that
+       timestamps can be adjusted.  Patch by Elan Feingold
+       <efeingold@mn.rr.com>.
+
 2003-02-25  Dick Porter  <dick@ximian.com>
 
        * shared.c (_wapi_shm_attach): Return a failure code on system
index 1a6b9c07489482ee1129ae55d91085dbf2f03402..b4b5a28862dc756d1233eb9b1bcfba1043f52d82 100644 (file)
@@ -1373,6 +1373,20 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
        }
        
        ret=open(filename, flags, perms);
+    
+       /* If we were trying to open a directory with write permissions
+        * (e.g. O_WRONLY or O_RDWR), this call will fail with
+        * EISDIR. However, this is a bit bogus because calls to
+        * manipulate the directory (e.g. SetFileTime) will still work on
+        * the directory because they use other API calls
+        * (e.g. utime()). Hence, if we failed with the EISDIR error, try
+        * to open the directory again without write permission.
+        */
+       if (ret == -1 && errno == EISDIR)
+       {
+               /* Try again but don't try to make it writable */
+               ret=open(filename, flags  & ~(O_RDWR|O_WRONLY), perms);
+       }
        
        if(ret==-1) {
 #ifdef DEBUG