summaryrefslogtreecommitdiff
path: root/test/scopedfile.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-12-23 21:10:54 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2020-12-23 22:35:52 +0100
commitdce64999d3325c5b55499d6ba657066efa48fbff (patch)
tree6b515b1d6a5b2caf63e0e7b180259cfba3a08e8a /test/scopedfile.cc
parent7df0197c7fb39650a7a428eb3b28e8f289ad54d3 (diff)
Fix unit-test compilation on windows.
Diffstat (limited to 'test/scopedfile.cc')
-rw-r--r--test/scopedfile.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/scopedfile.cc b/test/scopedfile.cc
index b03a2bc..3c30734 100644
--- a/test/scopedfile.cc
+++ b/test/scopedfile.cc
@@ -34,6 +34,9 @@
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#endif
struct Pimpl
@@ -50,8 +53,8 @@ ScopedFile::ScopedFile(const std::string& data)
pimpl->fd = mkstemp(templ);
#else
char templ[] = "dg-scoped-file-XXXXXX"; // buffer for filename
- _mktemp_s(templ);
- pimpl->fd = open(templ);
+ _mktemp_s(templ, sizeof(templ));
+ pimpl->fd = open(templ, O_CREAT | O_RDWR);
#endif
pimpl->filename = templ;
auto sz = write(pimpl->fd, data.data(), data.size());