20 #if defined(__linux__) || \ 21 defined(__FreeBSD_kernel__) || \ 23 defined(__unix__) || \ 24 defined(__CYGWIN__) || \ 37 DWORD dwBufSize = MAX_PATH+1;
38 char lpPathBuffer[MAX_PATH+1];
39 DWORD dwRetVal = GetTempPathA(dwBufSize, lpPathBuffer);
41 if(dwRetVal > dwBufSize || (dwRetVal == 0))
42 throw "GetTempPath failed";
49 UINT uRetVal=GetTempFileNameA(lpPathBuffer,
"TLO", 0, t);
51 throw "GetTempFileName failed";
55 throw "_mkdir failed";
57 result=std::string(t);
60 std::string prefixed_name_template=
"/tmp/";
61 const char *TMPDIR_env=getenv(
"TMPDIR");
62 if(TMPDIR_env!=
nullptr)
63 prefixed_name_template=TMPDIR_env;
64 if(*prefixed_name_template.rbegin()!=
'/')
65 prefixed_name_template+=
'/';
66 prefixed_name_template+=name_template;
68 std::vector<char> t(prefixed_name_template.begin(), prefixed_name_template.end());
70 const char *td = mkdtemp(t.data());
72 throw "mkdtemp failed";
73 result=std::string(td);
103 if(chdir(
path.c_str())!=0)
std::string concat_dir_file(const std::string &directory, const std::string &file_name)
#define CHECK_RETURN(CONDITION)
std::string get_current_working_directory()
temp_dirt(const std::string &name_template)
std::string operator()(const std::string &file)
void delete_directory(const std::string &path)
deletes all files in 'path' and then the directory itself
temp_working_dirt(const std::string &name_template)
std::string old_working_directory
std::string get_temporary_directory(const std::string &name_template)