12 #include <util/pragma_push.def>
14 #pragma warning(disable:4668)
16 #pragma warning(disable : 5039)
22 #include <util/pragma_pop.def>
30 #if defined(__FreeBSD_kernel__) || \
32 defined(__unix__) || \
33 defined(__CYGWIN__) || \
48 DWORD dwBufSize = MAX_PATH + 1;
49 char lpPathBuffer[MAX_PATH + 1];
50 DWORD dwRetVal = GetTempPathA(dwBufSize, lpPathBuffer);
52 if(dwRetVal > dwBufSize || (dwRetVal == 0))
62 UINT uRetVal = GetTempFileNameA(lpPathBuffer,
"TLO", 0, t);
66 std::string(
"Couldn't get new temporary file name in directory") +
74 std::string(
"Couldn't create temporary directory at ") + t);
76 result = std::string(t);
79 std::string prefixed_name_template =
"/tmp/";
80 const char *TMPDIR_env = getenv(
"TMPDIR");
81 if(TMPDIR_env !=
nullptr)
82 prefixed_name_template = TMPDIR_env;
83 if(*prefixed_name_template.rbegin() !=
'/')
84 prefixed_name_template +=
'/';
85 prefixed_name_template += name_template;
88 prefixed_name_template.begin(), prefixed_name_template.end());
90 const char *td = mkdtemp(t.data());
95 char *wd = realpath(td,
nullptr);
99 std::string(
"realpath failed: ") + std::strerror(errno));
101 result = std::string(wd);