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; only version 2
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>
34 * Return pointer to home directory path using the env variable HOME.
35 * No home, NULL is returned.
37 const char *get_home_dir(void)
39 return ((const char *) getenv("HOME"));
45 * Create recursively directory using the FULL path.
47 int mkdir_recursive(const char *path
, mode_t mode
, gid_t gid
)
50 char *p
, tmp
[PATH_MAX
];
54 ret
= snprintf(tmp
, sizeof(tmp
), "%s", path
);
56 perror("snprintf mkdir");
61 if (tmp
[len
- 1] == '/') {
66 for (p
= tmp
+ 1; *p
; p
++) {
69 ret
= mkdir(tmp
, mode
);
71 if (!(errno
== EEXIST
)) {
72 perror("mkdir recursive");
81 ret
= mkdir(tmp
, mode
);
This page took 0.031785 seconds and 4 git commands to generate.