2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <sys/types.h>
31 int mkdir_recursive(const char *path
, mode_t mode
)
34 char *p
, tmp
[PATH_MAX
];
38 ret
= snprintf(tmp
, sizeof(tmp
), "%s", path
);
40 perror("snprintf mkdir");
45 if (tmp
[len
- 1] == '/') {
50 for (p
= tmp
+ 1; *p
; p
++) {
53 ret
= mkdir(tmp
, mode
);
55 if (!(errno
== EEXIST
)) {
56 perror("mkdir recursive");
65 ret
= mkdir(tmp
, mode
);
This page took 0.046178 seconds and 4 git commands to generate.