summaryrefslogtreecommitdiff
path: root/compat/mkdir.c
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2013-09-27 17:19:40 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2013-09-27 17:19:40 +0000
commit7bf8e474d15414eda8520ba5258511d845ca6061 (patch)
tree417d6cfc8946fce8e2f87fdf3ec964036abd495c /compat/mkdir.c
parent45d74c4b0fe38218b4569a90da7102cf48d616c2 (diff)
parente230c568c4b9a991e3175e5f65171a566fd8e39c (diff)
downloadgit-7bf8e474d15414eda8520ba5258511d845ca6061.tar.gz
Merge tag 'v1.8.4' into baserock/morph
Git 1.8.4
Diffstat (limited to 'compat/mkdir.c')
-rw-r--r--compat/mkdir.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/compat/mkdir.c b/compat/mkdir.c
new file mode 100644
index 0000000000..9e253fb72f
--- /dev/null
+++ b/compat/mkdir.c
@@ -0,0 +1,24 @@
+#include "../git-compat-util.h"
+#undef mkdir
+
+/* for platforms that can't deal with a trailing '/' */
+int compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode)
+{
+ int retval;
+ char *tmp_dir = NULL;
+ size_t len = strlen(dir);
+
+ if (len && dir[len-1] == '/') {
+ if ((tmp_dir = strdup(dir)) == NULL)
+ return -1;
+ tmp_dir[len-1] = '\0';
+ }
+ else
+ tmp_dir = (char *)dir;
+
+ retval = mkdir(tmp_dir, mode);
+ if (tmp_dir != dir)
+ free(tmp_dir);
+
+ return retval;
+}