mkstemp---generate unused file name
#include <stdio.h> char *mktemp(char *path); int mkstemp(char *path); char *_mktemp_r(void *reent, char *path); int *_mkstemp_r(void *reent, char *path);
mkstemp attempt to generate a file name that is not
yet in use for any existing file.
mkstemp creates the file and
opens it for reading and writing;
mktemp simply generates the file name.
You supply a simple pattern for the generated file name, as the string
at path. The pattern should be a valid filename (including path
information if you wish) ending with some number of `
characters. The generated filename will match the leading part of the
name you supply, with the trailing `
X' characters replaced by some
combination of digits and letters.
The alternate functions
_mkstemp_r are reentrant
versions. The extra argument reent is a pointer to a reentrancy
mktemp returns the pointer path to the modified string
representing an unused filename, unless it could not generate one, or
the pattern you provided is not suitable for a filename; in that case,
mkstemp returns a file descriptor to the newly created file,
unless it could not generate an unused filename, or the pattern you
provided is not suitable for a filename; in that case, it returns
ANSI C does not require either
mkstemp; the System
V Interface Definition requires
mktemp as of Issue 2.
Supporting OS subroutines required:
Go to the first, previous, next, last section, table of contents.