All the directories in the file system form a tree starting at the root directory. A file name can specify all the directory names starting from the root of the tree; then it is called an absolute file name. Or it can specify the position of the file in the tree relative to a default directory; then it is called a relative file name. On Unix and GNU/Linux, an absolute file name starts with a slash or a tilde (‘~’), and a relative one does not. On MS-DOS and MS-Windows, an absolute file name starts with a slash or a backslash, or with a drive specification ‘x:/’, where x is the drive letter.
This function returns
tif file filename is an absolute file name,
nilotherwise.(file-name-absolute-p "~rms/foo") ⇒ t (file-name-absolute-p "rms/foo") ⇒ nil (file-name-absolute-p "/user/rms/foo") ⇒ t
Given a possibly relative file name, you can convert it to an
absolute name using
expand-file-name (see File Name Expansion). This function converts absolute file names to relative
This function tries to return a relative name that is equivalent to filename, assuming the result will be interpreted relative to directory (an absolute directory name or directory file name). If directory is omitted or
nil, it defaults to the current buffer's default directory.
On some operating systems, an absolute file name begins with a device name. On such systems, filename has no relative equivalent based on directory if they start with two different device names. In this case,
file-relative-namereturns filename in absolute form.(file-relative-name "/foo/bar" "/foo/") ⇒ "bar" (file-relative-name "/foo/bar" "/hack/") ⇒ "../foo/bar"