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