[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

[MD:1764] Bug fix of file-readable-p



Eli Zaretskii <eliz@xxxxxxxxxxxxx> writes:

>   + #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;
> 
> IIRC, `stat' fails (returns -1) on Windows for root directories.  If I'm 
> right, this means that file-writable-p, as you suggest to patch it, will 
> return nil for any file in the root directory of any drive.

Because NTEmacs implements stat() by itself,
your surmise does not hold.
The following tests follow it.

(file-writable-p "c:/")
-->t
(file-writable-p "c:/AUTOEXEC.BAT")
-->t

NTEmacs frequently uses stat() in many functions.
So if it fails, we would meet many troubles on file I/O.

from himi