12 #include <util/pragma_push.def>
14 #pragma warning(disable:4668)
16 #pragma warning(disable : 5039)
22 #include <util/pragma_pop.def>
29 #if defined(__linux__) || \
30 defined(__FreeBSD_kernel__) || \
32 defined(__unix__) || \
33 defined(__CYGWIN__) || \
47 DWORD dwBufSize = MAX_PATH + 1;
48 char lpPathBuffer[MAX_PATH + 1];
49 DWORD dwRetVal = GetTempPathA(dwBufSize, lpPathBuffer);
51 if(dwRetVal > dwBufSize || (dwRetVal == 0))
61 UINT uRetVal = GetTempFileNameA(lpPathBuffer,
"TLO", 0, t);
65 std::string(
"Couldn't get new temporary file name in directory") +
73 std::string(
"Couldn't create temporary directory at ") + t);
75 result = std::string(t);
78 std::string prefixed_name_template =
"/tmp/";
79 const char *TMPDIR_env = getenv(
"TMPDIR");
80 if(TMPDIR_env !=
nullptr)
81 prefixed_name_template = TMPDIR_env;
82 if(*prefixed_name_template.rbegin() !=
'/')
83 prefixed_name_template +=
'/';
84 prefixed_name_template += name_template;
87 prefixed_name_template.begin(), prefixed_name_template.end());
89 const char *td = mkdtemp(t.data());
94 char *wd = realpath(td,
nullptr);
96 if(wd ==
nullptr || errno != 0)
98 std::string(
"realpath failed: ") + std::strerror(errno));
100 result = std::string(wd);