Improve documentation of 'file-exists-p'

* doc/lispref/files.texi (Testing Accessibility): Document better
how to test for existing dangling symlinks.  (Bug#60146)
This commit is contained in:
Eli Zaretskii 2022-12-17 22:14:40 +02:00
parent c9015ef55f
commit 627e7e0243

View file

@ -895,10 +895,14 @@ permissions of the file itself.)
If the file does not exist, or if there was trouble determining If the file does not exist, or if there was trouble determining
whether the file exists, this function returns @code{nil}. whether the file exists, this function returns @code{nil}.
Directories are files, so @code{file-exists-p} can return @code{t} when @cindex dangling symlinks, testing for existence
given a directory. However, because @code{file-exists-p} follows Directories are files, so @code{file-exists-p} can return @code{t}
symbolic links, it returns @code{t} for a symbolic link when given a directory. However, because @code{file-exists-p} follows
name only if the target file exists. symbolic links, it returns @code{t} for a symbolic link name only if
the target of the link exists; if your Lisp program needs to consider
@dfn{dangling symlinks} whose target doesn't exist as existing files,
use @code{file-attributes} (@pxref{File Attributes}) instead of
@code{file-exists-p}.
@end defun @end defun
@defun file-readable-p filename @defun file-readable-p filename