| 90 | |
| 91 | #ifdef _WIN32 |
| 92 | int cbm_mkstemp(char *tmpl) { |
| 93 | /* Rewrite /tmp/ to %TEMP%\ like cbm_mkdtemp */ |
| 94 | static char buf[CBM_SZ_512]; |
| 95 | if (strncmp(tmpl, "/tmp/", 5) == 0) { |
| 96 | const char *tmp = getenv("TEMP"); |
| 97 | if (!tmp) |
| 98 | tmp = getenv("TMP"); |
| 99 | if (!tmp) |
| 100 | tmp = "."; |
| 101 | snprintf(buf, sizeof(buf), "%s\\%s", tmp, tmpl + 5); |
| 102 | } else { |
| 103 | snprintf(buf, sizeof(buf), "%s", tmpl); |
| 104 | } |
| 105 | if (!_mktemp(buf)) |
| 106 | return CBM_NOT_FOUND; |
| 107 | int fd = _open(buf, _O_CREAT | _O_RDWR | _O_BINARY, _S_IREAD | _S_IWRITE); |
| 108 | if (fd >= 0) |
| 109 | strcpy(tmpl, buf); |
| 110 | return fd; |
| 111 | } |
| 112 | #endif |
| 113 | |
| 114 | /* ── clock_gettime (Windows lacks it) ─────────────────────────── */ |
no outgoing calls