FAT | RFS | XFS | ZFS
tmpnam()
PROTOTYPE
#include <stdio.h>
char *tmpnam(char *s);
DESCRIPTION
tmpnam() creates a filename that is unique within the CWD. If s is not NULL, a name of up to L_tmpnam characters, including a terminating null, is written to it. Otherwise it stores the name in a static array and returns the array’s address. Subsequent calls to tmpnam() alter this array.
If a task calls tmpnam() and is preempted before creating a file with the name, another task could call tmpnam() and get the same name. However, that is unlikely because tmpnam() can be called TMP_MAX times before it reuses the same name. If needed, vol_lock() and vol_unlock() can be used to atomically get a name and create a file with it.
L_tmpnam and TMP_MAX are defined in “stdio.h”.
EXAMPLE
char fname[L_tmpnam];
/*-----------------------------------------------------------------*/
/* Get a unique name for a temporary file. */
/*-----------------------------------------------------------------*/
tmpnam(fname);