Next: Truenames, Previous: Testing Accessibility, Up: Information about Files
This section describes how to distinguish various kinds of files, such as directories, symbolic links, and ordinary files.
If the file filename is a symbolic link, the
file-symlink-pfunction returns the (non-recursive) link target as a string. (Determining the file name that the link points to from the target is nontrivial.) First, this function recursively follows symbolic links at all levels of parent directories.If the file filename is not a symbolic link (or there is no such file),
file-symlink-preturnsnil.(file-symlink-p "foo") ⇒ nil (file-symlink-p "sym-link") ⇒ "foo" (file-symlink-p "sym-link2") ⇒ "sym-link" (file-symlink-p "/bin") ⇒ "/pub/bin"
The next two functions recursively follow symbolic links at all levels for filename.
This function returns
tif filename is the name of an existing directory,nilotherwise.(file-directory-p "~rms") ⇒ t (file-directory-p "~rms/lewis/files.texi") ⇒ nil (file-directory-p "~rms/lewis/no-such-file") ⇒ nil (file-directory-p "$HOME") ⇒ nil (file-directory-p (substitute-in-file-name "$HOME")) ⇒ t
This function returns
tif the file filename exists and is a regular file (not a directory, named pipe, terminal, or other I/O device).
This function returns
tif the files file1 and file2 name the same file. If file1 or file2 does not exist, the return value is unspecified.
This function returns
tif file is a file in directory dir, or in a subdirectory of dir. It also returnstif file and dir are the same directory. It compares thefile-truenamevalues of the two directories (see Truenames). If dir does not name an existing directory, the return value isnil.