| 59 | return pc_path(path, sizeof(path), f->repo, leaf) && pc_write(path, text); |
| 60 | } |
| 61 | static bool pc_copy(const char *from, const char *to) { |
| 62 | FILE *a = cbm_fopen(from, "rb"), *b = cbm_fopen(to, "wb"); |
| 63 | bool ok = a && b; |
| 64 | unsigned char bytes[4096]; |
| 65 | while (ok) { |
| 66 | size_t n = fread(bytes, 1, sizeof(bytes), a); |
| 67 | if (n && fwrite(bytes, 1, n, b) != n) { ok = false; break; } |
| 68 | if (n < sizeof(bytes)) { ok = !ferror(a); break; } |
| 69 | } |
| 70 | if (a && fclose(a) != 0) ok = false; |
| 71 | if (b && fclose(b) != 0) ok = false; |
| 72 | return ok; |
| 73 | } |
| 74 | static bool pc_files_equal(const char *left, const char *right) { |
| 75 | FILE *a = cbm_fopen(left, "rb"), *b = cbm_fopen(right, "rb"); |
| 76 | bool ok = a && b; |
no test coverage detected