summaryrefslogtreecommitdiff
path: root/test/scopedfile.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/scopedfile.cc')
-rw-r--r--test/scopedfile.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/scopedfile.cc b/test/scopedfile.cc
index e63972e..b03a2bc 100644
--- a/test/scopedfile.cc
+++ b/test/scopedfile.cc
@@ -31,6 +31,11 @@
#include <cpp11fix.h>
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
struct Pimpl
{
std::string filename;
@@ -40,8 +45,14 @@ struct Pimpl
ScopedFile::ScopedFile(const std::string& data)
: pimpl(std::make_unique<struct Pimpl>())
{
+#ifndef _WIN32
char templ[] = "/tmp/dg-scoped-file-XXXXXX"; // buffer for filename
pimpl->fd = mkstemp(templ);
+#else
+ char templ[] = "dg-scoped-file-XXXXXX"; // buffer for filename
+ _mktemp_s(templ);
+ pimpl->fd = open(templ);
+#endif
pimpl->filename = templ;
auto sz = write(pimpl->fd, data.data(), data.size());
(void)sz;