OSDN Git Service

105a9e436320ec44f3b8af69958959d77f4fcdcc
[linuxjm/LDP_man-pages.git] / original / man3 / mkdtemp.3
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.
13 .\"
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.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .TH MKDTEMP 3  2010-09-26 "GNU" "Linux Programmer's Manual"
25 .SH NAME
26 mkdtemp \- 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
33 .sp
34 .in -4n
35 Feature Test Macro Requirements for glibc (see
36 .BR feature_test_macros (7)):
37 .in
38 .sp
39 .BR mkdtemp ():
40 .br
41 .ad l
42 .RS 4
43 .PD 0
44 _BSD_SOURCE
45 .br
46 || /* Since glibc 2.10: */
47 .RS 4
48 (_POSIX_C_SOURCE\ >=\ 200809L || _XOPEN_SOURCE\ >=\ 700)
49 .ad
50 .PD
51 .RE
52 .SH DESCRIPTION
53 The
54 .BR mkdtemp ()
55 function generates a uniquely named temporary
56 directory from \fItemplate\fP.
57 The last six characters of \fItemplate\fP
58 must be XXXXXX and these are replaced with a string that makes the
59 directory name unique.
60 The directory is then created with
61 permissions 0700.
62 Since it will be modified,
63 .I template
64 must not be a string constant, but should be declared as a character array.
65 .SH "RETURN VALUE"
66 The
67 .BR mkdtemp ()
68 function returns a pointer to the modified template
69 string on success, and NULL on failure, in which case
70 .I errno
71 is set appropriately.
72 .SH ERRORS
73 .TP
74 .B EINVAL
75 The last six characters of \fItemplate\fP were not XXXXXX.
76 Now \fItemplate\fP is unchanged.
77 .PP
78 Also see
79 .BR mkdir (2)
80 for other possible values for \fIerrno\fP.
81 .SH VERSIONS
82 Available since glibc 2.1.91.
83 .SH "CONFORMING TO"
84 POSIX.1-2008.
85 This function is present on the BSDs.
86 .\" As at 2006, this function is being considered for a revision of POSIX.1
87 .\" Also in NetBSD 1.4.
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)