|
|
BSD 4.3reno
.\" Copyright (c) 1989 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted provided .\" that: (1) source distributions retain this entire copyright notice and .\" comment, and (2) distributions including binaries display the following .\" acknowledgement: ``This product includes software developed by the .\" University of California, Berkeley and its contributors'' in the .\" documentation or other materials provided with the distribution and in .\" all advertising materials mentioning features or use of this software. .\" Neither the name of the University nor the names of its contributors may .\" be used to endorse or promote products derived from this software without .\" specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)mktemp.3 6.7 (Berkeley) 6/23/90 .\" .TH MKTEMP 3 "June 23, 1990" .AT 3 .SH NAME mktemp \- create a unique file name .SH SYNOPSIS .nf .ft B char * mktemp(template) char *template; .sp mkstemp(template) char *template; .ft R .fi .SH DESCRIPTION .I Mktemp takes a file name template and overwrites it to create a unique file name for use by the application. The template may be any file name with some number of X's appended to it, for example ``/tmp/temp.XXXX''. The trailing X's are replaced with the current process number and/or a unique letter combination. The number of unique file names .I mktemp can return depends on the number of X's provided; six X's will result in .I mktemp testing roughly 26 ** 6 combinations. .PP .I Mkstemp makes the same replacement to the template and creates the template file, mode 0600, 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. .SH "RETURN VALUE" .I Mktemp returns a pointer to the template on success and NULL on failure. .I Mkstemp returns -1 if no suitable file could be created. If either call fails an error code is placed in the global location .IR errno . .SH ERRORS .I Mktemp and .I mkstemp may set .I errno to one of the following values: .TP [ENOTDIR] The pathname portion of the template is not an existing directory. .PP .I Mktemp and .I mkstemp may also set .I errno to any value specified by the .IR stat (2) function. .I Mkstemp may also set .I errno to any value specified by the .IR open (2) function. .SH "SEE ALSO" chmod(2), getpid(2), open(2), stat(2)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.