summaryrefslogtreecommitdiff
path: root/src/win32
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-08-30 13:34:14 +0200
committerVicent Marti <tanoku@gmail.com>2011-08-30 13:34:14 +0200
commitf978b748bb50beb0ccbebc3aa118ad289e4c9cba (patch)
tree701bde8e9edb4e4066a4ea54375668c3ae9c3d32 /src/win32
parent3ef7d06302b97a24167cd1ceafeb08b871df1751 (diff)
downloadlibgit2-f978b748bb50beb0ccbebc3aa118ad289e4c9cba.tar.gz
compat: Move `mkstemp` to the POSIX compat layer
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/posix.c17
-rw-r--r--src/win32/posix.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/src/win32/posix.c b/src/win32/posix.c
index 0e9d3f0f4..aac56ce84 100644
--- a/src/win32/posix.c
+++ b/src/win32/posix.c
@@ -1,6 +1,7 @@
#include "posix.h"
#include "path.h"
#include <errno.h>
+#include <io.h>
int p_unlink(const char *path)
{
@@ -230,3 +231,19 @@ int p_snprintf(char *buffer, size_t count, const char *format, ...)
return r;
}
+
+int p_mkstemp(char *tmp_path)
+{
+ int r;
+
+#if defined(_MSC_VER)
+ r = _mktemp_s(tmp_path, GIT_PATH_MAX);
+#else
+ r = _mktemp(tmp_path);
+#endif
+
+ if (r != 0)
+ return GIT_EOSERR;
+
+ return p_creat(tmp_path, 0744);
+}
diff --git a/src/win32/posix.h b/src/win32/posix.h
index 536089e44..28d978959 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -25,5 +25,6 @@ extern int p_hide_directory__w32(const char *path);
extern char *p_realpath(const char *orig_path, char *buffer);
extern int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr);
extern int p_snprintf(char *buffer, size_t count, const char *format, ...) GIT_FORMAT_PRINTF(3, 4);
+extern int p_mkstemp(char *tmp_path);
#endif