summaryrefslogtreecommitdiff
path: root/src/posix.c
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-05-06 13:04:12 +0200
committernulltoken <emeric.fermas@gmail.com>2012-05-07 12:18:54 +0200
commit3191ae89c65c1685fdae59e03e1af7d7e8edabd8 (patch)
tree9f990d404fbc3317eaf92a2aa84413ab48b1cfb2 /src/posix.c
parent9b62e40ecdb92ab7493eac514e1399d791fa6f62 (diff)
downloadlibgit2-3191ae89c65c1685fdae59e03e1af7d7e8edabd8.tar.gz
compat: make p_open able to accept optional mode when passing the O_CREAT flag
This has the nice side effect of making test_attr_repo__staging_properly_normalizes_line_endings_according_to_gitattributes_directives() test pass again on Windows. This test started to fail after commit 674a198 was applied.
Diffstat (limited to 'src/posix.c')
-rw-r--r--src/posix.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/posix.c b/src/posix.c
index a3f81d767..cecb538eb 100644
--- a/src/posix.c
+++ b/src/posix.c
@@ -12,9 +12,20 @@
#ifndef GIT_WIN32
-int p_open(const char *path, int flags)
+int p_open(const char *path, int flags, ...)
{
- return open(path, flags | O_BINARY);
+ mode_t mode = 0;
+
+ if (flags & O_CREAT)
+ {
+ va_list arg_list;
+
+ va_start(arg_list, flags);
+ mode = va_arg(arg_list, mode_t);
+ va_end(arg_list);
+ }
+
+ return open(path, flags | O_BINARY, mode);
}
int p_creat(const char *path, mode_t mode)