From a6e00a4d222cfc432757b5e46f65adb2c524f928 Mon Sep 17 00:00:00 2001 From: Tobias Frisch <tfrisch@uni-koblenz.de> Date: Sat, 17 Jul 2021 17:13:58 +0200 Subject: [PATCH] [#100] Fix for Windows being special of course Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de> --- src/vkcv/File.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/vkcv/File.cpp b/src/vkcv/File.cpp index 52c6d3d3..df303afc 100644 --- a/src/vkcv/File.cpp +++ b/src/vkcv/File.cpp @@ -2,7 +2,14 @@ #include "vkcv/File.hpp" #include <stdlib.h> + +#ifdef _WIN32 +#include <io.h> +#else #include <unistd.h> +#endif + +#include "vkcv/Logger.hpp" namespace vkcv { @@ -15,13 +22,25 @@ namespace vkcv { } char name [16] = "vkcv_tmp_XXXXXX"; + +#ifdef _WIN32 + int err = _mktemp_s(name, 16); + + if (err != 0) { + vkcv_log(LogLevel::ERROR, "Temporary file path could not be generated"); + return ""; + } +#else int fd = mkstemp(name); if (fd == -1) { + vkcv_log(LogLevel::ERROR, "Temporary file path could not be generated"); return ""; } close(fd); +#endif + return tmp / name; } -- GitLab