TMPFILE(3S) TMPFILE(3S)
tmpfile - create a temporary file
#include <stdio.h>
FILE *tmpfile (void);
tmpfile creates a temporary file, and returns a corresponding FILE
pointer. The file is created on the temporary directory indicated by the
string P_tmpdir in <stdio.h>. However, if the variable TMPDIR is
provided in the user's environment, the variable's value is the name of
the desired temporary-file directory. If the directory specified by the
variable TMPDIR is not accessible, the directory specified by the string
P_tmpdir in <stdio.h> will be used.
If the file cannot be opened, a NULL pointer is returned. Upon return
from tmpfile, you may print an error message using perror(3C), to
determine the reason for the failure. A success call to tmpfile will
create a temporary file just long enough to obtain the FILE pointer, then
delete the file with unlink(2), and finally return the FILE pointer to
the calling process. Thus, the only means of accessing the temporary
file is though the FILE pointer. The file is opened for update ("w+").
Although the name of the temporary file is generated similarly to those
produced by tmpnam(3S), tmpfile uses its own algorithm to generate
filenames similar to, but unique from, those generated by tmpnam. This
allocates the entire space of tmpnam-generated names to applications
code. (See tmpnam(3S) for more information.)
ENVIRONMENT VARIABLES [Toc] [Back] TMPDIR
If the environment variable TMPDIR is provided, it is used as the
desired temporary-file directory. The support for the TMPDIR
environment variable is introduced in IRIX 6.5.9.
creat(2), unlink(2), fopen(3S), mktemp(3C), perror(3C), stdio(3S),
tmpnam(3S).
PPPPaaaaggggeeee 1111 [ Back ]
|