Check that file exists: Difference between revisions

new Emacs Lisp
(new Emacs Lisp)
Line 464:
require(file.isDirectory(), fn { `$file is not a directory!` })
}</lang>
 
=={{header|Emacs Lisp}}==
<lang Lisp>(file-exists-p "input.txt")
(file-directory-p "docs")
(file-exists-p "/input.txt")
(file-directory-p "/docs")</lang>
 
<code>file-exists-p</code> is true on both files and directories. <code>file-directory-p</code> is true only on directories. Both go through the <code>file-name-handler-alist</code> "magic filenames" mechanism so can act on remote files. On MS-DOS generally both <code>/</code> and <code>\</code> work to specify the root directory.
 
=={{header|Erlang}}==