MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CompareFiles

Function CompareFiles

src/strgen/strgen.cpp:171–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171static 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. */
186struct FileWriter {

Callers 1

FinaliseMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected