| 237 | } |
| 238 | |
| 239 | static bool watcher_git_output_create(watcher_git_output_t *output) { |
| 240 | if (!output) { |
| 241 | return false; |
| 242 | } |
| 243 | memset(output, 0, sizeof(*output)); |
| 244 | int written = |
| 245 | snprintf(output->path, sizeof(output->path), "%s/cbm-watcher-git-XXXXXX", cbm_tmpdir()); |
| 246 | if (written <= 0 || written >= (int)sizeof(output->path)) { |
| 247 | output->path[0] = '\0'; |
| 248 | return false; |
| 249 | } |
| 250 | int descriptor = cbm_mkstemp(output->path); |
| 251 | if (descriptor < 0) { |
| 252 | output->path[0] = '\0'; |
| 253 | return false; |
| 254 | } |
| 255 | #ifdef _WIN32 |
| 256 | bool closed = _close(descriptor) == 0; |
| 257 | #else |
| 258 | bool closed = close(descriptor) == 0; |
| 259 | #endif |
| 260 | if (!closed) { |
| 261 | watcher_git_output_cleanup(output); |
| 262 | } |
| 263 | return closed; |
| 264 | } |
| 265 | |
| 266 | #ifdef _WIN32 |
| 267 | /* CreateProcessW does not search PATH when lpApplicationName is non-NULL. |
no test coverage detected