From d0db131a73933d0a6c65bab59d1e0e4f6a185338 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 6 Jun 2020 13:58:22 +0200 Subject: Code cleanup, use gcc 8 on debian 10 --- libcommon/tempfile.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'libcommon/tempfile.cpp') diff --git a/libcommon/tempfile.cpp b/libcommon/tempfile.cpp index 5d3a086..c30bb57 100644 --- a/libcommon/tempfile.cpp +++ b/libcommon/tempfile.cpp @@ -1,5 +1,9 @@ #include "tempfile.h" +#include +#include +#include + #include namespace fs = std::filesystem; @@ -12,7 +16,12 @@ fs::path Tempfile::GetPath() const Tempfile::Tempfile() { try { - m_path = std::string{tmpnam(NULL)} + ".zip"s; + char name[] = "/tmp/tempfileXXXXXX.zip"; + int fd = mkstemps(name, 4); + if (fd == -1) + std::runtime_error("mkstemps: "s + strerror(errno)); + close(fd); + m_path = std::string{name}; } catch (const std::exception& ex) { throw std::runtime_error("Tempfile error: "s + ex.what()); } -- cgit v1.2.3