From c102dc8c786ae3760b2ccdafb8d6429f801e59b1 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 16 Jun 2018 21:13:54 +0200 Subject: Make directory handling cross-platform in unit-tests. --- test/scopedfile.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/scopedfile.cc') 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 +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + struct Pimpl { std::string filename; @@ -40,8 +45,14 @@ struct Pimpl ScopedFile::ScopedFile(const std::string& data) : pimpl(std::make_unique()) { +#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; -- cgit v1.2.3