(Ffile_writable_p) [WINDOWSNT]: Return nil if parent
authorGerd Moellmann <gerd@gnu.org>
Thu, 20 Apr 2000 21:01:16 +0000 (21:01 +0000)
committerGerd Moellmann <gerd@gnu.org>
Thu, 20 Apr 2000 21:01:16 +0000 (21:01 +0000)
directory doesn't exist.

src/fileio.c

index 545061b..59d09a9 100644 (file)
@@ -2947,8 +2947,17 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0,
 #endif /* MSDOS */
 
   dir = ENCODE_FILE (dir);
+#ifdef WINDOWSNT
+  /* The read-only attribute of the parent directory doesn't affect
+     whether a file or directory can be created within it.  Some day we
+     should check ACLs though, which do affect this.  */
+  if (stat (XSTRING (dir)->data, &statbuf) < 0)
+    return Qnil;
+  return (statbuf.st_mode & S_IFMT) == S_IFDIR ? Qt : Qnil;
+#else
   return (check_writable (!NILP (dir) ? (char *) XSTRING (dir)->data : "")
          ? Qt : Qnil);
+#endif
 }
 \f
 DEFUN ("access-file", Faccess_file, Saccess_file, 2, 2, 0,