]> git.ipfire.org Git - thirdparty/git.git/blame - compat/mkdir.c
Start the 2.46 cycle
[thirdparty/git.git] / compat / mkdir.c
CommitLineData
0539ecfd
JS
1#include "../git-compat-util.h"
2#undef mkdir
3
4/* for platforms that can't deal with a trailing '/' */
5int compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode)
6{
7 int retval;
8 char *tmp_dir = NULL;
9 size_t len = strlen(dir);
10
11 if (len && dir[len-1] == '/') {
afe8a907 12 if (!(tmp_dir = strdup(dir)))
0539ecfd
JS
13 return -1;
14 tmp_dir[len-1] = '\0';
15 }
16 else
17 tmp_dir = (char *)dir;
18
19 retval = mkdir(tmp_dir, mode);
20 if (tmp_dir != dir)
21 free(tmp_dir);
22
23 return retval;
24}