blob: 5d3a086a19e17a3710a3f562145b6687aafae8be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include "tempfile.h"
#include <iostream>
namespace fs = std::filesystem;
using namespace std::string_literals;
fs::path Tempfile::GetPath() const
{
return m_path;
}
Tempfile::Tempfile() {
try {
m_path = std::string{tmpnam(NULL)} + ".zip"s;
} catch (const std::exception& ex) {
throw std::runtime_error("Tempfile error: "s + ex.what());
}
}
Tempfile::~Tempfile() {
try {
fs::remove_all(m_path);
} catch (const std::exception& ex) {
std::cerr << "Warning: Couldn't remove temporary file " << m_path << std::endl;
}
}
|