unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Null filename ("") is considered to correspond to an existing, readable, and writable file?
@ 2006-01-02 22:57 Drew Adams
  2006-01-03  1:22 ` Luc Teirlinck
  0 siblings, 1 reply; 22+ messages in thread
From: Drew Adams @ 2006-01-02 22:57 UTC (permalink / raw)


The following expressions all return true (on Windows, at least). I imagine
that this is by design (it is an old policy), but I don't understand the
reason for this.

 (file-exists-p "")
 (file-readable-p "")
 (file-writable-p "")

How often would someone want a null filename to be considered to correspond
to an existing, readable, or writable file?

This means that code that tests a filename needs to do something like this:

 (and (not (string= "" name)) (file-readable-p name))

For example, when prompting a user for the name of a readable file, I guess
you need to do something like this:

(while (or (string= "" name) (not (file-readable-p name)))
  (setq name (read-file-name prompt...)))

Why?

This behavior also seems to contradict the doc strings. They say clearly
that the file with the given name really exists, is really readable, or is
really writable.

Also, the doc strings and the manual say nothing about using a default
directory (yes, apparently) or whether the FILENAME argument must include a
directory (it need not, apparently).

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2006-01-07 20:04 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-02 22:57 Null filename ("") is considered to correspond to an existing, readable, and writable file? Drew Adams
2006-01-03  1:22 ` Luc Teirlinck
2006-01-03  3:27   ` Drew Adams
2006-01-03  4:41     ` Luc Teirlinck
2006-01-03  8:24       ` Drew Adams
2006-01-03 18:13       ` Eli Zaretskii
2006-01-03  4:56     ` Luc Teirlinck
2006-01-03  5:32     ` Eli Zaretskii
2006-01-03  8:25       ` Drew Adams
2006-01-03 15:50         ` Stefan Monnier
2006-01-03 18:51           ` Drew Adams
2006-01-03 19:16             ` Eli Zaretskii
2006-01-03 19:25               ` Drew Adams
2006-01-03 19:40             ` Luc Teirlinck
2006-01-03 20:23             ` Luc Teirlinck
2006-01-03 21:09               ` Drew Adams
2006-01-07 20:04             ` Thien-Thi Nguyen
2006-01-03 18:11         ` Eli Zaretskii
2006-01-03 18:51           ` Drew Adams
2006-01-03 19:13             ` Eli Zaretskii
2006-01-03 19:23               ` Drew Adams
2006-01-03 18:51           ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).