2008-04-17 Dick Porter <dick@ximian.com>
authorDick Porter <dick@acm.org>
Thu, 17 Apr 2008 18:44:47 +0000 (18:44 -0000)
committerDick Porter <dick@acm.org>
Thu, 17 Apr 2008 18:44:47 +0000 (18:44 -0000)
* io.c (DeleteFile): Return ERROR_ACCESS_DENIED if the file is
readonly.  Fixes bug 378229.

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

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

index 98b49c7b71652d1563aee613c2cf61740076b759..ccec3a74fefa06cd3fb70cf7e3f02bf0e15a91cb 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-17  Dick Porter  <dick@ximian.com>
+
+       * io.c (DeleteFile): Return ERROR_ACCESS_DENIED if the file is
+       readonly.  Fixes bug 378229.
+
 2008-04-11  Geoff Norton  <gnorton@novell.com>
 
        * processes.c: The global extern environ doesn't exist on Mac.  We
index b9834f114c0c166d2286d8f9ff3b59ef5af58316..77c85f5e963cc63aaf7bae2892f787d19e320118 100644 (file)
@@ -1688,6 +1688,7 @@ gboolean DeleteFile(const gunichar2 *name)
        gchar *filename;
        int retval;
        gboolean ret = FALSE;
+       guint32 attrs;
        
        if(name==NULL) {
 #ifdef DEBUG
@@ -1707,6 +1708,23 @@ gboolean DeleteFile(const gunichar2 *name)
                SetLastError (ERROR_INVALID_NAME);
                return(FALSE);
        }
+
+       attrs = GetFileAttributes (name);
+       if (attrs == INVALID_FILE_ATTRIBUTES) {
+#ifdef DEBUG
+               g_message ("%s: file attributes error", __func__);
+#endif
+               /* Error set by GetFileAttributes() */
+               return(FALSE);
+       }
+
+       if (attrs & FILE_ATTRIBUTE_READONLY) {
+#ifdef DEBUG
+               g_message ("%s: file %s is readonly", __func__, filename);
+#endif
+               SetLastError (ERROR_ACCESS_DENIED);
+               return(FALSE);
+       }
        
        retval = _wapi_unlink (filename);