Common Lisp Package: TEMPORARY-FILE

README:

PLEASE DO NOT USE THIS LIBRARY, IT HAS BEEN INCORPORATED INTO https://github.com/edicl/cl-fad

temporary-file

Common Lisp temporary file creation library

FUNCTION

Public

OPEN-TEMPORARY (&REST OPEN-ARGUMENTS &KEY (TEMPLATE *DEFAULT-TEMPLATE*) (GENERATE-RANDOM-STRING 'GENERATE-RANDOM-STRING) (MAX-TRIES *MAX-TRIES*) (DIRECTION OUTPUT) &ALLOW-OTHER-KEYS)

Create a file with a randomly generated name and return the opened stream. The resulting pathname is generated from TEMPLATE, which is a string representing a pathname template. A percent sign (%) in that string is replaced by a randomly generated string to make the filename unique. The default for TEMPLATE places temporary files in the TEMPORARY-FILES logical pathname host, which is automatically set up in a system specific manner. The file name generated from TEMPLATE is merged with *DEFAULT-PATHNAME-DEFAULTS*, so random pathnames relative to that directory can be generated by not specifying a directory in TEMPLATE. GENERATE-RANDOM-STRING can be passed to override the default function that generates the random name component. It should return a random string consisting of characters that are permitted in a pathname (logical or physical, depending on TEMPLATE). The name of the temporary file can be accessed calling the PATHNAME function on STREAM. For convenience, the temporary file is opened on the physical pathname, i.e. if the TEMPLATE designate a logical pathname the translation to a physical pathname is performed before opening the stream. In order to create a unique file name, OPEN-TEMPORARY may loop internally up to MAX-TRIES times before giving up and signalling a CANNOT-CREATE-TEMPORARY-FILE condition.

Private

GETENV (X)

Query the libc runtime environment. See getenv(3).

Undocumented

DIRECTORY-FROM-ENVIRONMENT (ENVIRONMENT-VARIABLE-NAME)

GENERATE-RANDOM-PATHNAME (TEMPLATE RANDOM-STRING-GENERATOR)

GENERATE-RANDOM-STRING

GET-DEFAULT-TEMPORARY-DIRECTORY

MACRO

Public

WITH-OPEN-TEMPORARY-FILE ((STREAM &REST ARGS &KEY KEEP &ALLOW-OTHER-KEYS) &BODY BODY)

Create a temporary file using OPEN-TEMPORARY with ARGS and run BODY with STREAM bound to the temporary file stream. Returns the values returned by BODY. By default, the file is deleted when BODY is exited. If a true value is passed in KEEP, the file is not deleted when the body is exited. See OPEN-TEMPORARY for more permitted options.

WITH-OUTPUT-TO-TEMPORARY-FILE ((STREAM &REST ARGS) &BODY BODY)

Create a temporary file using OPEN-TEMPORARY with ARGS and run BODY with STREAM bound to the temporary file stream. Returns the pathname of the file that has been created. See OPEN-TEMPORARY for permitted options.

Private

Undocumented

WITH-FILE-NAME-LOCK-HELD (NIL &BODY BODY)

VARIABLE

Public

Undocumented

*DEFAULT-TEMPLATE*

Private

Undocumented

*CREATE-FILE-NAME-LOCK*

*MAX-TRIES*

*NAME-RANDOM-STATE*

CONDITION

Public

Undocumented

CANNOT-CREATE-TEMPORARY-FILE

INVALID-TEMPORARY-PATHNAME-TEMPLATE