46 DWORD dwBufSize = MAX_PATH + 1;
47 char lpPathBuffer[MAX_PATH + 1];
48 DWORD dwRetVal = GetTempPathA(dwBufSize, lpPathBuffer);
50 if(dwRetVal > dwBufSize || (dwRetVal == 0))
60 UINT uRetVal = GetTempFileNameA(lpPathBuffer,
"TLO", 0, t);
64 std::string(
"Couldn't get new temporary file name in directory") +
72 std::string(
"Couldn't create temporary directory at ") + t);
74 result = std::string(t);
77 std::string prefixed_name_template =
"/tmp/";
78 const char *TMPDIR_env = getenv(
"TMPDIR");
79 if(TMPDIR_env !=
nullptr)
80 prefixed_name_template = TMPDIR_env;
81 if(*prefixed_name_template.rbegin() !=
'/')
82 prefixed_name_template +=
'/';
83 prefixed_name_template += name_template;
86 prefixed_name_template.begin(), prefixed_name_template.end());
88 const char *td = mkdtemp(t.data());
93 char *wd = realpath(td,
nullptr);
97 std::string(
"realpath failed: ") + std::strerror(errno));
99 result = std::string(wd);