[PATCH21.4] Fix windows support for readonly files

Vin Shelton acs at alumni.princeton.edu
Thu Jan 4 19:15:47 EST 2007


I think this patch (against 21.4 in CVS) fixes the problems identified:

1) I can once again edit a non-existent file in a write-protected directory
2) XEmacs respects the readonly bit
3) the infloop on "xemacs -vanilla nonexistent_file" problem has gone away.

Please review.  I will commit if no one objects.

  - Vin

Index: src/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.290.2.117
diff -a -u -r1.290.2.117 ChangeLog
--- src/ChangeLog       2007/01/02 01:32:40     1.290.2.117
+++ src/ChangeLog       2007/01/04 22:34:51
@@ -1,3 +1,8 @@
+2007-01-04  Vin Shelton  <acs at xemacs.org>
+
+       * fileio.c (check_writable): Check old-style readonly bit only for
+       non-directories.
+
 2006-12-25  Benson I. Margulies  <benson at dchbk.us>

        * src/fileio.c (check_writable):
Index: src/fileio.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/fileio.c,v
retrieving revision 1.66.2.9
diff -a -u -r1.66.2.9 fileio.c
--- src/fileio.c        2007/01/02 01:32:45     1.66.2.9
+++ src/fileio.c        2007/01/04 22:34:52
@@ -2307,17 +2307,18 @@
   filename = filename_buffer;
 #endif

-  // ask simple question first
+  // First check for a normal file with the old-style readonly bit
   attributes = GetFileAttributes(filename);
-  if (0 != (attributes & FILE_ATTRIBUTE_READONLY))
-      return 0;
+  if (FILE_ATTRIBUTE_READONLY == (attributes &
(FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_READONLY)))
+    return 0;

   /* Win32 prototype lacks const. */
   error = GetNamedSecurityInfo((LPTSTR)filename, SE_FILE_OBJECT,

DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION,
                                &psidOwner, &psidGroup, &pDacl, &pSacl, &pDesc);
   if (error != ERROR_SUCCESS) { // FAT?
-      return 1;
+    attributes = GetFileAttributes(filename);
+    return (attributes & FILE_ATTRIBUTE_DIRECTORY) || (0 ==
(attributes & FILE_ATTRIBUTE_READONLY));
   }

   genericMapping.GenericRead = FILE_GENERIC_READ;

-- 
The Journey by Mary Oliver
http://www.poemhunter.com/p/m/poem.asp?poet=6771&poem=30506



More information about the XEmacs-Beta mailing list