Create a temporary directory. Returns static buffer with path. * Pattern: prefix is used as part of the dirname. */
| 158 | /* Create a temporary directory. Returns static buffer with path. |
| 159 | * Pattern: prefix is used as part of the dirname. */ |
| 160 | static inline char *th_mktempdir(const char *prefix) { |
| 161 | static char buf[256]; |
| 162 | #ifdef _WIN32 |
| 163 | const char *tmp = getenv("TEMP"); |
| 164 | if (!tmp) |
| 165 | tmp = getenv("TMP"); |
| 166 | if (!tmp) |
| 167 | tmp = "C:\\Temp"; |
| 168 | snprintf(buf, sizeof(buf), "%s\\%s_XXXXXX", tmp, prefix); |
| 169 | #else |
| 170 | snprintf(buf, sizeof(buf), "/tmp/%s_XXXXXX", prefix); |
| 171 | #endif |
| 172 | if (!cbm_mkdtemp(buf)) { |
| 173 | return NULL; |
| 174 | } |
| 175 | return buf; |
| 176 | } |
| 177 | |
| 178 | /* Runtime IPC validates the complete Windows directory ancestry, so an MSYS2 |
| 179 | * TEMP rooted under C:/msys64/tmp is intentionally unsuitable even when the |
no test coverage detected