15 #if defined(__FreeBSD_kernel__) || \
16 defined(__CYGWIN__) || \
37 result = std::filesystem::temp_directory_path().string();
39 catch(
const std::filesystem::filesystem_error &)
44 std::string prefixed_name_template =
"/tmp/";
45 const char *TMPDIR_env =
getenv(
"TMPDIR");
46 if(TMPDIR_env !=
nullptr)
47 prefixed_name_template = TMPDIR_env;
48 if(*prefixed_name_template.rbegin() !=
'/')
49 prefixed_name_template +=
'/';
50 prefixed_name_template += name_template;
53 prefixed_name_template.begin(), prefixed_name_template.end());
55 const char *td = mkdtemp(t.data());
60 char *wd = realpath(td,
nullptr);
66 result = std::string(wd);
80 return std::filesystem::path(
path).append(file).string();
85 std::filesystem::remove_all(
path);
Thrown when some external system fails unexpectedly.
temp_dirt(const std::string &name_template)
std::string operator()(const std::string &file)
char * getenv(const char *name)
char * strerror(int errnum)
std::string get_temporary_directory(const std::string &name_template)