7#include "slideio/core/slideio_core_def.hpp"
11 class SLIDEIO_CORE_EXPORTS TempFile
14 explicit TempFile(std::filesystem::path path) : m_path(path)
16 if(std::filesystem::exists(path))
17 std::filesystem::remove(path);
19 TempFile() : TempFile(static_cast<const char*>(nullptr))
23 explicit TempFile(
const char* ext)
25 std::string pattern(
"%%%%-%%%%-%%%%-%%%%.");
26 if(ext ==
nullptr || *ext==0){
32 m_path = std::filesystem::temp_directory_path();
33 m_path /= unique_path(pattern);
35 const std::filesystem::path& getPath()
const{
40 if(std::filesystem::exists(m_path))
41 std::filesystem::remove(m_path);
43 static std::filesystem::path unique_path(
const std::string& model =
"%%%%-%%%%-%%%%-%%%%");
45 std::filesystem::path m_path;
Definition: exceptions.hpp:15