Main index | Section 3 | 日本語 | Options |
#include <stdio.h>
The tmpnam() function returns a pointer to a file name, in the P_tmpdir directory, which did not reference an existing file at some indeterminate point in the past. P_tmpdir is defined in the include file <stdio.h>. If the argument str is non- NULL, the file name is copied to the buffer it references. Otherwise, the file name is copied to a static buffer. In either case, tmpnam() returns a pointer to the file name.
The buffer referenced by str is expected to be at least L_tmpnam bytes in length. L_tmpnam is defined in the include file <stdio.h>.
The tempnam() function is similar to tmpnam(), but provides the ability to specify the directory which will contain the temporary file and the file name prefix.
The environment variable TMPDIR (if set), the argument tmpdir (if non- NULL), the directory P_tmpdir, and the directory /tmp are tried, in the listed order, as directories in which to store the temporary file.
The argument prefix, if non- NULL, is used to specify a file name prefix, which will be the first part of the created file name. The tempnam() function allocates memory in which to store the file name; the returned pointer may be used as a subsequent argument to free(3).
The tmpnam() and tempfile() functions return a pointer to a file name on success, and a NULL pointer on error.
TMPDIR | |
[tempnam() and tmpfile() only] If set, the directory in which the temporary file is stored. TMPDIR is ignored for processes for which issetugid(2) is true. | |
Most historic implementations of these functions provide only a limited number of possible temporary file names (usually 26) before file names will start being recycled. System V implementations of these functions (and of mktemp(3)) use the access(2) system call to determine whether or not the temporary file may be created. This has obvious ramifications for setuid or setgid programs, complicating the portable use of these interfaces in such programs.
The tmpfile() interface should not be used in software expected to be used on other systems if there is any possibility that the user does not wish the temporary file to be publicly readable and writable.
The tmpnam() function may fail and set errno for any of the errors specified for the library function mktemp(3).
The tempnam() function may fail and set errno for any of the errors specified for the library functions malloc(3) or mktemp(3).
TMPFILE (3) | August 7, 2020 |
Main index | Section 3 | 日本語 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | The last good thing written in C was Franz Schubert's Symphony #9. | ” |
— Erwin Dietrich |