summaryrefslogtreecommitdiffhomepage
path: root/libcommon/tempfile.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-06-06 13:58:22 +0200
committerRoland Reichwein <mail@reichwein.it>2020-06-06 13:58:22 +0200
commitd0db131a73933d0a6c65bab59d1e0e4f6a185338 (patch)
tree06edad4d845c8ba4102843fc3b306d7b5cc485d6 /libcommon/tempfile.cpp
parent343922258d57261021daca42eb488c1205ae491c (diff)
Code cleanup, use gcc 8 on debian 10
Diffstat (limited to 'libcommon/tempfile.cpp')
-rw-r--r--libcommon/tempfile.cpp11
1 files changed, 10 insertions, 1 deletions
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 <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
#include <iostream>
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());
}