1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* On some systems, mkdir ("foo/", 0700) fails because of the trailing
4 slash. On those systems, this wrapper removes the trailing slash.
6 Copyright (C) 2001, 2003, 2006, 2008-2013 Free Software Foundation, Inc.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* written by Jim Meyering */
35 /* Disable the definition of mkdir to rpl_mkdir (from the <sys/stat.h>
36 substitute) in this file. Otherwise, we'd get an endless recursion. */
39 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
40 Additionally, it declares _mkdir (and depending on compile flags, an
41 alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
42 which are included in the <sys/stat.h> override. */
43 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
44 # define mkdir(name,mode) _mkdir (name)
45 # define maybe_unused _GL_UNUSED
47 # define maybe_unused /* empty */
50 /* This function is required at least for NetBSD 1.5.2. */
53 rpl_mkdir (char const *dir, mode_t mode maybe_unused)
57 size_t len = strlen (dir);
59 if (len && dir[len - 1] == '/')
61 tmp_dir = strdup (dir);
64 /* Rather than rely on strdup-posix, we set errno ourselves. */
68 strip_trailing_slashes (tmp_dir);
72 tmp_dir = (char *) dir;
74 #if FUNC_MKDIR_DOT_BUG
75 /* Additionally, cygwin 1.5 mistakenly creates a directory "d/./". */
77 char *last = last_component (tmp_dir);
78 if (*last == '.' && (last[1] == '\0'
79 || (last[1] == '.' && last[2] == '\0')))
82 if (stat (tmp_dir, &st) == 0)
87 #endif /* FUNC_MKDIR_DOT_BUG */
89 ret_val = mkdir (tmp_dir, mode);