| 169 | } |
| 170 | |
| 171 | static bool CompareFiles(const std::filesystem::path &path1, const std::filesystem::path &path2) |
| 172 | { |
| 173 | /* Check for equal size, but ignore the error code for cases when a file does not exist. */ |
| 174 | std::error_code error_code; |
| 175 | if (std::filesystem::file_size(path1, error_code) != std::filesystem::file_size(path2, error_code)) return false; |
| 176 | |
| 177 | std::ifstream stream1(path1, std::ifstream::binary); |
| 178 | std::ifstream stream2(path2, std::ifstream::binary); |
| 179 | |
| 180 | return std::equal(std::istreambuf_iterator<char>(stream1.rdbuf()), |
| 181 | std::istreambuf_iterator<char>(), |
| 182 | std::istreambuf_iterator<char>(stream2.rdbuf())); |
| 183 | } |
| 184 | |
| 185 | /** Base class for writing data to disk. */ |
| 186 | struct FileWriter { |