tmpnam — C Library Procedures
NAME
tmpnam, tempnam − Generate unique names for temporary files
SYNOPSIS
include <stdio.h>
char ∗
tmpnam(s)
char ∗
tempnam(dir, prefix)
ARGUMENTS
char ∗sin/out Place to store temporary file name. If NULL, store name in local static storage that will be overwritten on next call to tmpnam. If not NULL, s must point to a buffer containing at least L_tmpnam bytes.
char ∗dirin Directory in which to temporary file should reside. If NULL, or if dir is not an accessible directory, defaults to P_tmpdir.
char ∗prefix (in) First few letters to use for name of temporary file.
DESCRIPTION
The procedures tmpnam and tempnam generate unique file names suitable for temporary files. Each procedure returns a pointer to the name it generated, except that under some conditions (such as inability to allocate memory, for example) tempnam will fail to generate a file name. When this happens, tempnam will return NULL.
Tmpnam generates file names that refer to a standard directory defined by P_tmpdir (currently /usr/tmp). Each time tmpnam is called it will return a different file name, which does not refer to any existing file.
Tempnam is similar to tmpnam except that it provides more flexibility. The dir argument may be used to specify a particular directory to which the generated name should refer. If this is not an accessible directory, then P_tmpdir will be used. If this directory is not accessible either, then /tmp will be used as a last resort. If the TMPDIR environment variable is defined and refers to an accessible directory, then it will override any of the above choices.
The prefix argument may be used to specify the first few letters of the last component of the path name generated by tempnam. Tempnam dynamically allocates space for the name using malloc. It is the responsibility of the caller to release this storage by passing the returned string to free when it is no longer needed.
KEYWORDS
file name, temporary, unique
Sprite version 1.0 — October 03, 1989