Next: , Previous: Directories, Up: Osicat

1.4 Files and Symbolic Links

— Function: file-exists-p pathspec &optional file-kind

Checks whether the file named by the pathname designator pathspec exists, if this is the case and file-kind is specified it also checks the file kind. If the tests succeed, return two values: truename and file kind of pathspec, nil otherwise. Follows symbolic links.

— Function: regular-file-exists-p pathspec

Checks whether the file named by the pathname designator pathspec exists and is a regular file. Returns its truename if this is the case, nil otherwise. Follows symbolic links.

— Function: file-kind pathspec &key follow-symlinks

Returns a keyword indicating the kind of file designated by pathspec, or nil if the file does not exist. Does not follow symbolic links by default.

Possible file-kinds in addition to nil are: :regular-file, :symbolic-link, :directory, :pipe, :socket, :character-device, and :block-device. If follow-symlinks is non-NIL and pathspec designates a broken symlink returns :broken as second value.

Signals an error if pathspec is wild.

— Function: file-permissions pathspec

file-permissions returns a list of keywords identifying the permissions of pathspec.

setf file-permissions sets the permissions of pathspec as identified by the symbols in list.

If pathspec designates a symbolic link, that link is implicitly resolved.

Permission symbols consist of :user-read, :user-write, :user-exec, :group-read, :group-write, :group-exec, :other-read, :other-write, :other-exec, :set-user-id, :set-group-id, and :sticky.

Both signal an error if pathspec is wild, or doesn't designate an existing file.

— Function: open-temporary-file &key pathspec element-type external-format

Creates a temporary file setup for input and output, and returns a stream connected to that file.

pathspec serves as template for the file to be created: a certain number of random characters will be concatenated to the file component of pathspec. If pathspec has no directory component, the file will be created inside *temporary-directory*. The file itself is unlinked once it has been opened.

element-type specifies the unit of transaction of the stream. Consider using with-temporary-file instead of this function.

On failure, a file-error may be signalled.

— Macro: with-temporary-file (stream &key pathspec element-type external-format) &body body

Within the lexical scope of the body, stream is connected to a temporary file as created by open-temporary-file. The file is closed automatically once body exits.

— Function: make-link link &key target hard

Creates link that points to target. Defaults to a symbolic link, but giving a non-NIL value to the keyword argument :hard creates a hard link. Returns the pathname of the link.

Relative targets are resolved against the link. Relative links are resolved against *default-pathname-defaults*.

Signals an error if either target or link is wild, target does not exist, or link exists already.

— Function: read-link pathspec

Returns the pathname pointed to by the symbolic link designated by pathspec. If the link is relative, then the returned pathname is relative to the link, not *default-pathname-defaults*.

Signals an error if pathspec is wild, or does not designate a symbolic link.