init: kill set_git_dir_init()
[alt-git.git] / compat / mkdir.c
blob9e253fb72f2df92a09b562dde59f347c4c207a57
1 #include "../git-compat-util.h"
2 #undef mkdir
4 /* for platforms that can't deal with a trailing '/' */
5 int compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode)
7 int retval;
8 char *tmp_dir = NULL;
9 size_t len = strlen(dir);
11 if (len && dir[len-1] == '/') {
12 if ((tmp_dir = strdup(dir)) == NULL)
13 return -1;
14 tmp_dir[len-1] = '\0';
16 else
17 tmp_dir = (char *)dir;
19 retval = mkdir(tmp_dir, mode);
20 if (tmp_dir != dir)
21 free(tmp_dir);
23 return retval;