mkstemp
From Wikipedia, the free encyclopedia
|
|
The topic of this article may not meet Wikipedia's general notability guideline. Please help to establish notability by adding reliable, secondary sources about the topic. If notability cannot be established, the article is likely to be merged, redirected, or deleted. (October 2008) |
In computing, mkstemp is a POSIX function for creating a temporary file (a computer file which usually ceases to exist when the program, which opened the file, closes it or terminates).[1]
Contents |
[edit] Usage
[edit] Inclusion
- C
#include <stdlib.h> // per IEEE Std 1003.1, 2004 #include <unistd.h> // for "legacy" systems
- C++
#include <cstdlib> // per IEEE Std 1003.1, 2004 #include <unistd.h> // for "legacy" systems
[edit] Declaration
int mkstemp(char* template);
[edit] Requirements
- The parameter
templatemust be a modifiable, null-terminated character array. - The contents of
templatemust be in the format of a valid file path, with six trailing 'X's. - The parameter
templatemust not have been used in a previous invocation ofmkstemp.
[edit] Semantics
- The trailing 'X's in
templateare overwritten to generate a unique file name for the resulting temporary file. - The function reports a valid file descriptor to a temporary file on success; on failure, it reports
-1.
[edit] Error conditions
It is unspecified if mkstemp sets errno, and what values of errno are set, in the event of failure.[1]