Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkstemp.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkstemp.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkstemp.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkstemp.html on line 8

mkstemp()

Make a unique temporary filename, and open the file

Synopsis:

#include <stdlib.h>

int mkstemp( char* template );

Arguments:

template
A template for the filename that you want to use. This template can be any file name with some number of Xs appended to it, for example /tmp/temp.XXXX.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The mkstemp() function takes the given file name template and overwrites a portion of it to create a filename. This file name is unique and suitable for use by the application. The trailing Xs are replaced with the current process number and/or a unique letter combination. The number of unique file names mkstemp() can return depends on the number of Xs provided; if you specify six Xs, mkstemp() tests roughly 266 combinations.

The mkstemp() function (unlike mktemp()) creates the template file, mode 0600 (i.e. read-write for the owner), returning a file descriptor opened for reading and writing. This avoids the race between testing for a file's existence and opening it for use.

Returns:

The file descriptor of the temporary file, or -1 if no suitable file could be created; errno is set.

Errors:

ENOTDIR
The pathname portion of the template isn't an existing directory.

This function may also set errno to any value specified by open() and stat().

Classification:

POSIX 1003.1 XSI

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

Caveats:

It's possible to run out of letters. The mkstemp() function doesn't check to determine whether the file name part of template exceeds the maximum allowable filename length.

For portability with X/Open standards prior to XPG4v2, use tmpfile() instead.

See also:

chmod(). getpid(). mktemp(), open() stat(). tmpfile(), tmpnam()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkstemp.html on line 165

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkstemp.html on line 165