Debian Codegraph @

upstream/debian-trixie/man3/mkdtemp.3

raw
1 '\" t
2 .\" Copyright 2001 John Levon <[email protected]>
3 .\" Based on mkstemp(3), Copyright 1993 David Metcalfe ([email protected])
4 .\" and GNU libc documentation
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .TH mkdtemp 3 2024-05-02 "Linux man-pages 6.9.1"
8 .SH NAME
9 mkdtemp \- create a unique temporary directory
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ", " \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <stdlib.h>
16 .P
17 .BI "char *mkdtemp(char *" template );
18 .fi
19 .P
20 .RS -4
21 Feature Test Macro Requirements for glibc (see
22 .BR feature_test_macros (7)):
23 .RE
24 .P
25 .BR mkdtemp ():
26 .nf
27 /* Since glibc 2.19: */ _DEFAULT_SOURCE
28 || /* glibc 2.19 and earlier: */ _BSD_SOURCE
29 || /* Since glibc 2.10: */ _POSIX_C_SOURCE >= 200809L
30 .fi
31 .SH DESCRIPTION
32 The
33 .BR mkdtemp ()
34 function generates a uniquely named temporary
35 directory from \fItemplate\fP.
36 The last six characters of \fItemplate\fP
37 must be XXXXXX and these are replaced with a string that makes the
38 directory name unique.
39 The directory is then created with
40 permissions 0700.
41 Since it will be modified,
42 .I template
43 must not be a string constant, but should be declared as a character array.
44 .SH RETURN VALUE
45 The
46 .BR mkdtemp ()
47 function returns a pointer to the modified template
48 string on success, and NULL on failure, in which case
49 .I errno
50 is set to indicate the error.
51 .SH ERRORS
52 .TP
53 .B EINVAL
54 The last six characters of \fItemplate\fP were not XXXXXX.
55 Now \fItemplate\fP is unchanged.
56 .P
57 Also see
58 .BR mkdir (2)
59 for other possible values for \fIerrno\fP.
60 .SH ATTRIBUTES
61 For an explanation of the terms used in this section, see
62 .BR attributes (7).
63 .TS
64 allbox;
65 lbx lb lb
66 l l l.
67 Interface Attribute Value
68 T{
69 .na
70 .nh
71 .BR mkdtemp ()
72 T} Thread safety MT-Safe
73 .TE
74 .SH STANDARDS
75 POSIX.1-2008.
76 .SH HISTORY
77 glibc 2.1.91.
78 NetBSD 1.4.
79 POSIX.1-2008.
80 .SH SEE ALSO
81 .BR mktemp (1),
82 .BR mkdir (2),
83 .BR mkstemp (3),
84 .BR mktemp (3),
85 .BR tempnam (3),
86 .BR tmpfile (3),
87 .BR tmpnam (3)