| 95 | return fclose(file) == 0 && ok; |
| 96 | } |
| 97 | static bool pf_files_equal(const char *a, const char *b) { |
| 98 | FILE *left = cbm_fopen(a, "rb"), *right = cbm_fopen(b, "rb"); |
| 99 | bool ok = left && right; |
| 100 | unsigned char x[4096], y[4096]; |
| 101 | while (ok) { |
| 102 | size_t nx = fread(x, 1, sizeof(x), left), ny = fread(y, 1, sizeof(y), right); |
| 103 | if (nx != ny || memcmp(x, y, nx)) { |
| 104 | ok = false; |
| 105 | break; |
| 106 | } |
| 107 | if (nx < sizeof(x)) { |
| 108 | ok = !ferror(left) && !ferror(right); |
| 109 | break; |
| 110 | } |
| 111 | } |
| 112 | if (left && fclose(left)) |
| 113 | ok = false; |
| 114 | if (right && fclose(right)) |
| 115 | ok = false; |
| 116 | return ok; |
| 117 | } |
| 118 | static bool pf_directory_only(const char *directory, const char *allowed) { |
| 119 | cbm_dir_t *dir = cbm_opendir(directory); |
| 120 | if (!dir) |
no test coverage detected