1mkdtemp(3)                 Library Functions Manual                 mkdtemp(3)
2
3
4

NAME

6       mkdtemp - create a unique temporary directory
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <stdlib.h>
13
14       char *mkdtemp(char *template);
15
16   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
17
18       mkdtemp():
19           /* Since glibc 2.19: */ _DEFAULT_SOURCE
20               || /* glibc 2.19 and earlier: */ _BSD_SOURCE
21               || /* Since glibc 2.10: */ _POSIX_C_SOURCE >= 200809L
22

DESCRIPTION

24       The  mkdtemp()  function generates a uniquely named temporary directory
25       from template.  The last six characters of template must be XXXXXX  and
26       these  are replaced with a string that makes the directory name unique.
27       The directory is then created with permissions 0700.  Since it will  be
28       modified,  template  must  not  be a string constant, but should be de‐
29       clared as a character array.
30

RETURN VALUE

32       The mkdtemp() function returns  a  pointer  to  the  modified  template
33       string  on  success, and NULL on failure, in which case errno is set to
34       indicate the error.
35

ERRORS

37       EINVAL The last six characters of template were not XXXXXX.   Now  tem‐
38              plate is unchanged.
39
40       Also see mkdir(2) for other possible values for errno.
41

ATTRIBUTES

43       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
44       tributes(7).
45
46       ┌────────────────────────────────────────────┬───────────────┬─────────┐
47Interface                                   Attribute     Value   
48       ├────────────────────────────────────────────┼───────────────┼─────────┤
49mkdtemp()                                   │ Thread safety │ MT-Safe │
50       └────────────────────────────────────────────┴───────────────┴─────────┘
51

STANDARDS

53       POSIX.1-2008.
54

HISTORY

56       glibc 2.1.91.  NetBSD 1.4.  POSIX.1-2008.
57

SEE ALSO

59       mktemp(1), mkdir(2),  mkstemp(3),  mktemp(3),  tempnam(3),  tmpfile(3),
60       tmpnam(3)
61
62
63
64Linux man-pages 6.04              2023-03-30                        mkdtemp(3)
Impressum