| 172 | } |
| 173 | |
| 174 | static bool watcher_git_output_create(watcher_git_output_t *output) { |
| 175 | if (!output) { |
| 176 | return false; |
| 177 | } |
| 178 | memset(output, 0, sizeof(*output)); |
| 179 | int written = |
| 180 | snprintf(output->path, sizeof(output->path), "%s/cbm-watcher-git-XXXXXX", cbm_tmpdir()); |
| 181 | if (written <= 0 || written >= (int)sizeof(output->path)) { |
| 182 | output->path[0] = '\0'; |
| 183 | return false; |
| 184 | } |
| 185 | int descriptor = cbm_mkstemp(output->path); |
| 186 | if (descriptor < 0) { |
| 187 | output->path[0] = '\0'; |
| 188 | return false; |
| 189 | } |
| 190 | #ifdef _WIN32 |
| 191 | bool closed = _close(descriptor) == 0; |
| 192 | #else |
| 193 | bool closed = close(descriptor) == 0; |
| 194 | #endif |
| 195 | if (!closed) { |
| 196 | watcher_git_output_cleanup(output); |
| 197 | } |
| 198 | return closed; |
| 199 | } |
| 200 | |
| 201 | #ifdef _WIN32 |
| 202 | /* CreateProcessW does not search PATH when lpApplicationName is non-NULL. |
no test coverage detected