| 197 | } |
| 198 | |
| 199 | static int cx_copy_file(const char *src, const char *dst) { |
| 200 | FILE *in = fopen(src, "rb"); |
| 201 | if (!in) { |
| 202 | return -1; |
| 203 | } |
| 204 | FILE *out = fopen(dst, "wb"); |
| 205 | if (!out) { |
| 206 | fclose(in); |
| 207 | return -1; |
| 208 | } |
| 209 | char buf[4096]; |
| 210 | size_t n; |
| 211 | while ((n = fread(buf, 1, sizeof(buf), in)) > 0) { |
| 212 | fwrite(buf, 1, n, out); |
| 213 | } |
| 214 | fclose(in); |
| 215 | fclose(out); |
| 216 | return 0; |
| 217 | } |
| 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) { |
no test coverage detected