Next: File Objects, Up: Files [Contents][Index]
A file name is a string identifying an individual file (or directory) in the filing system (i.e. the disk). The exact syntax of file names depends on the operating system. There are several functions for manipulating file names.
Returns true when file-name is not specified relative to the current directory.
This function returns the directory part of the file name string file-name. This is the substring of file-name defining the directory containing the file.
(file-name-directory "/tmp/foo")
⇒ "/tmp/"
(file-name-directory "foo")
⇒ ""
(file-name-directory "foo/bar/")
⇒ "foo/bar/"
Returns the substring of the file name file-name which is not the directory part.
(file-name-nondirectory "/tmp/foo")
⇒ "foo"
(file-name-nondirectory "foo")
⇒ "foo"
(file-name-nondirectory "foo/bar/")
⇒ ""
Returns a string through which the item in the file system named by file-name can be referred to as a directory.
(file-name-as-directory "./foo")
⇒ "./foo/"
(file-name-as-directory "./foo/")
⇒ "./foo/"
Returns a string through which the directory named by directory-name can be referred to as a file.
(directory-file-name "./foo/")
⇒ "./foo"
(directory-file-name "./foo")
⇒ "./foo"
Expands file-name assuming that it specifies a file relative to
base-dir. If base-dir is undefined it is taken as the
current value of the default-directory variable. While expanding
the file name, any obvious simplifications will be performed (e.g. on
Unix the removal of "." and ".." where possible).
Note that the returned file name will only be absolute if one of the following conditions is met:
default-directory) is absolute,
(expand-file-name "foo" "./bar")
⇒ "bar/foo"
Note for file handler implementors: when a handler is called for the
expand-file-name operation, it will only ever receive one
argument, the already expanded file name. The only action that may be
need to be taken is to simplify the file name (e.g. removing .
and .. entries or whatever).
This function returns the canonical name of the file referred to by the string file-name. The canonical name of a file is defined such that two files can be compared simply by comparing their canonical names; if the names match, they refer to the same file.
(Note that the opposite isn’t always true, if two canonical names don’t match the files could still be the same, for example via hard links. On most operating systems, symbolic links will be expanded where possible.
(canonical-file-name "foo")
⇒ "/home/john/src/librep/man/foo"
Librep supports extensible file handling (see File Handlers), so file names may refer to files not residing in the system’s local file structure, and thus which are unavailable to other programs.
This function returns either the absolute name of the file file-name, if it is found in the local system, or false, if the file does not.
(local-file-name "foo")
⇒ "/home/john/src/librep/man/foo"
(local-file-name "/john@tango:foo")
⇒ ()
This function returns the name of a file which, when created, may be used for temporary storage. Each time this function is called a unique name is computed.
(make-temp-name)
⇒ "/tmp/00088aaa"
(make-temp-name)
⇒ "/tmp/00088baa"
This variable names the current working directory. All relative file names are interpreted starting from this location in the file system.
Next: File Objects, Up: Files [Contents][Index]