Function | Package: system | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version

## temporary-directory

Arguments:

Returns the pathname of the temporary directory used by the current running Lisp for writing temporary files and sets, if necessary, the value of `sys:*temporary-directory*` to that directory.

This function works as follows:

1. The value of `sys:*temporary-directory*` is examined. If its value is `nil`, a new temporary directory is selected using the algorithm below.
2. The value of (probe-file sys:*temporary-directory*) is examined. If it is true, the value of `sys:*temporary-directory*` is returned. If the value returned by probe-file is `nil`, then a new temporary directory is selected using the algorithm below.

In a freshly installed Lisp image, the initial value of `sys:*temporary-directory*` is `nil`. However, in a user-built image (made with dumplisp or build-lisp-image or generate-application), `sys:*temporary-directory*` may have been given a value, which might or might not be a valid value on the machine where the image is run. If it is not a valid value, the behavior is the same as when the value is `nil`. But it can happen (perhaps unexpectedly) that the value is valid and in that case it is used.

### Algorithm for choosing a temporary directory

If a temporary directory must be chosen, it is chosen according to the following algorithms.

On UNIX and the Mac: #p"/tmp/".

On Windows: the first of the following to be a valid directory is used:

- the value of the environment variable TEMP
- the value of the environment variable TMP
- [current-drive]:\tmp
- C:\ (the last presumably always exists)

When a directory is chosen by this algorithm, the value of `sys:*temporary-directory*` is set to it.

This function does not work with setf. It is informational only. You can change the temporary directory by changing the value of `sys:*temporary-directory*` to the desired directory pathname. Whenever this function is called, it tests whether `(probe-file sys:*temporary-directory*)` returns true, returning the value of `sys:*temporary-directory*` when it is. If `(probe-file sys:*temporary-directory*)` returns `nil`, a new value is chosen using the algorithm above. Changing the temporary directory is not recommended.

Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.2 page.
Created 2012.5.30.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version