A fixture entry into `dst`: a file, or a directory with its contents. */
| 218 | |
| 219 | /* A fixture entry into `dst`: a file, or a directory with its contents. */ |
| 220 | static int cx_copy_entry(const char *src, const char *dst, bool is_dir) { |
| 221 | if (!is_dir) { |
| 222 | return cx_copy_file(src, dst); |
| 223 | } |
| 224 | if (th_mkdir_p(dst) != 0) { |
| 225 | return -1; |
| 226 | } |
| 227 | cbm_dir_t *d = cbm_opendir(src); |
| 228 | if (!d) { |
| 229 | return -1; |
| 230 | } |
| 231 | int rc = 0; |
| 232 | cbm_dirent_t *entry; |
| 233 | while ((entry = cbm_readdir(d)) != NULL) { |
| 234 | if (entry->name[0] == '.') { |
| 235 | continue; |
| 236 | } |
| 237 | char from[1024]; |
| 238 | char to[1024]; |
| 239 | snprintf(from, sizeof(from), "%s/%s", src, entry->name); |
| 240 | snprintf(to, sizeof(to), "%s/%s", dst, entry->name); |
| 241 | if (cx_copy_entry(from, to, entry->is_dir) != 0) { |
| 242 | rc = -1; |
| 243 | } |
| 244 | } |
| 245 | cbm_closedir(d); |
| 246 | return rc; |
| 247 | } |
| 248 | |
| 249 | /* ── Corpus builder ──────────────────────────────────────────────────── */ |
| 250 |
no test coverage detected