tmpnam()

generate name for temporary file 

Function


SYNOPSIS

#include <stdio.h>

char * tmpnam(char * s);


DESCRIPTION

The tmpnam() function generates a name for a temporary file. At the time that it is generated, the name is not in use by any existing file on the system. tmpnam() uses the TMPDIR environment variable as the path-prefix if set; otherwise, tmpnam() falls back to using the value of environment variable TMP, and then TEMP. Within a single process, the function tmpnam() will generate a new name each time it is called.

Because tmpnam() only generates a file name, rather than creating a file, it is possible that another application could create a file with the same name. The function tmpfile() is not vulnerable to this race condition.

The name returned by tmpnam() is temporary only in the sense that it is not the name of an existing file. It is the user's responsibility to delete any files he creates with names returned by tmpnam().


PARAMETERS

s 

Is either a null pointer, or a pointer to a buffer into which tmpnam() returns the result. The size of the buffer should be at least L_tmpnam bytes, where L_tmpnam is a constant defined in <stdio.h>.


RETURN VALUES

If s is not null, tmpnam() returns s. Otherwise, tmpnam() leaves its result in an internal static area and returns a pointer to that area, and the next call to tmpnam() overwrites the contents of the area.


CONFORMANCE

ANSI/ISO 9899-1990.


MULTITHREAD SAFETY LEVEL

Unsafe.


PORTING ISSUES

The function tmpnam() returns a UNIX-style path, with the disk volume represented as a top-level directory. For a discussion of pathing issues, see the Windows Concepts section of the PTC MKS Toolkit UNIX to Windows Porting Guide.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
tempnam(), tmpfile()


PTC MKS Toolkit 10.3 Documentation Build 39.