summaryrefslogtreecommitdiff
path: root/tests/win-shim.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/win-shim.h')
-rw-r--r--tests/win-shim.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/win-shim.h b/tests/win-shim.h
index a58c83d794cc..d870d96fc284 100644
--- a/tests/win-shim.h
+++ b/tests/win-shim.h
@@ -22,6 +22,8 @@
#include <direct.h>
#include <io.h>
+#include <fcntl.h>
+#include <sys/stat.h>
// Shims shared by both MSVC and MSYS2
#define mkdir(p, m) _mkdir(p)
@@ -51,6 +53,14 @@ mkdtemp(char *tmpl)
return NULL;
return tmpl;
}
+
+static inline int
+mkstemp(char *tmpl)
+{
+ if (_mktemp_s(tmpl, strlen(tmpl) + 1) != 0)
+ return -1;
+ return _open(tmpl, _O_CREAT | _O_EXCL | _O_RDWR | _O_BINARY, _S_IREAD | _S_IWRITE);
+}
#endif // _MSC_VER
#endif // _WIN32