Go to the first, previous, next, last section, table of contents.


File Names

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.

Function: file-name-directory file-name
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/"

Function: file-name-nondirectory file-name
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/")
    => ""

Function: file-name-concat &rest parts
This function returns a file name constructed by concatenating each of the parts of the file name together. Each part is separated by the necessary string (i.e. `/' on Unix) when necessary. Note that each part may contain more than one component of the file name.

(file-name-concat "/tmp" "foo" "bar")
    => "/tmp/foo/bar"

(file-name-concat "/tmp/" "foo/" "bar")
    => "/tmp/foo/bar"

(file-name-concat "/tmp/foo" "bar")
    => "/tmp/foo/bar"

Function: expand-file-name file-name &optional make-absolute
This function expands the string file-name into a valid file name. Currently it only checks for a leading tilde character (`~') when running on Unix, if one is found it's expanded to the user's home directory.

When the optional argument make-absolute is non-nil file-name is altered so that it is not relative to the current working directory. Generally this involves prefixing it by the absolute name of the current directory.

(expand-file-name "~/src")
    => "/home/jsh/src"

(expand-file-name "foo.c" t)
    => "/var/src/jade/foo.c"

Function: tmp-file-name
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.

(tmp-file-name)
    => "/tmp/00088aaa"

(tmp-file-name)
    => "/tmp/00088baa"


Go to the first, previous, next, last section, table of contents.