Function | Package: system | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Moderate update since the initial 10.1 release. 10.0 version

## make-temp-file-name

Arguments: &optional (prefix "temp")directory

Returns the namestring of a pathname of a non-existent file in directory. The filename will begin with prefix and additional characters added after prefix will ensure the file does not exist. prefix should be a string. The resulting filename will have no type.

The value of directory, if specified and non-`nil`, should be a pathname or a string coerceable to a pathname. If directory is relative, the resulting filename will have a relative directory component. That filename's existence will be tested by merging the directory with the current value of `*default-pathname-defaults*` and searching the resulting directory for the candidate file. The namestring of the successful candidate is returned as the file which does not exist. There is no guarantee that the result, merged with a different value of `*default-pathname-defaults*`, does not exist.

If directory (when merged with `*default-pathname-defaults*` if relative) does not exist, any candidate filename will of course not exist and the namestring of the first one tried will be returned. Users should ensure that the resulting directory component exists (with, say, ensure directories-exist) before trying to use the resulting file.

If directory is `nil` or unspecified, the value returned by sys:temporary-directory is used as the directory component of the resulting file.

This function does not create the file named by the returned value (that is, probe-file applied to the filename will return `nil` unless something other than the current Lisp process has created it). Neither will Lisp remove the file or ensure that the file is removed when Lisp exits. This function is for use by programs to determine suitable filenames for temporary use, but the program must take responsibility for creating and later deleting the file.

Filenames returned by this function should actually be created before this function is called again with the same arguments. Subsequent calls to this function with the same arguments are not guaranteed to be different unless the files named by earlier calls to this function are in fact created. (That is, this function simply looks at the existing files in directory and returns a filename that does not name an existing file.)

This function is used internally by Allegro CL.

### Examples

    cg-user(14): (sys:make-temp-file-name "foo" "c:/acl10.1.64/")
    "c:/acl10.1.64/fooa90201527236"

    ;; A relative directory path returns a relative result:
    cg-user(15): (sys:make-temp-file-name "foo" "tmp/")
    "tmp/fooa90201527237"

    ;; The directory specified need not exist.
    cg-user(45): (sys:make-temp-file-name "fooxxx" "/does/not/exist/")
    "/does/not/exist/fooxxxa902015272314"

    ;; That file cannot be used (by, say, passing it to OPEN) unless
    ;; PROBE-FILE applied to its directory returns true.
    ;; In this case it does not:

    cg-user(45): (sys:make-temp-file-name "fooxxx" "/does/not/exist/")
    "/does/not/exist/fooxxxa902015272314"
    cg-user(46): (probe-file (directory-namestring *))
    nil
    cg-user(47):

Copyright (c) 1998-2022, Franz Inc. Lafayette, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2019.8.20.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Moderate update since the initial 10.1 release. 10.0 version