]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mkdtemp.3
chdir.2, chmod.2, chown.2, gethostname.2, getsid.2, pread.2, setpgid.2, sigaltstack...
[thirdparty/man-pages.git] / man3 / mkdtemp.3
CommitLineData
fea681da
MK
1.\" Copyright 2001 John Levon <moz@compsoc.man.ac.uk>
2.\" Based on mkstemp(3), Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3.\" and GNU libc documentation
4.\"
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
c13182ef 13.\"
fea681da
MK
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
c13182ef 21.\"
fea681da
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
151429b8 24.TH MKDTEMP 3 2010-09-15 "GNU" "Linux Programmer's Manual"
fea681da
MK
25.SH NAME
26mkdtemp \- create a unique temporary directory
27.SH SYNOPSIS
28.nf
29.B #include <stdlib.h>
30.sp
31.BI "char *mkdtemp(char *" template );
32.fi
cc4615cc
MK
33.sp
34.in -4n
35Feature Test Macro Requirements for glibc (see
36.BR feature_test_macros (7)):
37.in
38.sp
39.BR mkdtemp ():
151429b8
MK
40.br
41.ad l
42.RS 4
43.PD 0
cc4615cc 44_BSD_SOURCE
3ba63d80
MK
45.br
46|| /* Since glibc 2.10: */
47.RS 4
48(_POSIX_C_SOURCE\ >=\ 200809L || _XOPEN_SOURCE\ >=\ 700)
49.ad
151429b8
MK
50.PD
51.RE
fea681da 52.SH DESCRIPTION
60a90ecd
MK
53The
54.BR mkdtemp ()
3f624b93 55function generates a uniquely named temporary
c13182ef
MK
56directory from \fItemplate\fP.
57The last six characters of \fItemplate\fP
fea681da 58must be XXXXXX and these are replaced with a string that makes the
c13182ef
MK
59directory name unique.
60The directory is then created with
fea681da
MK
61permissions 0700.
62Since it will be modified,
63.I template
64must not be a string constant, but should be declared as a character array.
65.SH "RETURN VALUE"
60a90ecd
MK
66The
67.BR mkdtemp ()
68function returns a pointer to the modified template
35e21ba7 69string on success, and NULL on failure, in which case
0daa9e92 70.I errno
fea681da
MK
71is set appropriately.
72.SH ERRORS
73.TP
74.B EINVAL
75The last six characters of \fItemplate\fP were not XXXXXX.
76Now \fItemplate\fP is unchanged.
cf0a9ace 77.PP
60a90ecd
MK
78Also see
79.BR mkdir (2)
80for other possible values for \fIerrno\fP.
2b2581ee
MK
81.SH VERSIONS
82Available since glibc 2.1.91.
fea681da 83.SH "CONFORMING TO"
1cc22815 84POSIX.1-2008.
2795ac0b 85This function is present on the BSDs.
68e1685c 86.\" As at 2006, this function is being considered for a revision of POSIX.1
fea681da 87.\" Also in NetBSD 1.4.
fea681da
MK
88.SH "SEE ALSO"
89.BR mkdir (2),
90.BR mkstemp (3),
91.BR mktemp (3),
92.BR tempnam (3),
93.BR tmpfile (3),
94.BR tmpnam (3)