MCPcopy Create free account
hub / github.com/Kitware/CMake / FilesDiffer

Method FilesDiffer

Source/kwsys/SystemTools.cxx:2282–2375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2280#define KWSYS_ST_BUFFER 4096
2281
2282bool SystemTools::FilesDiffer(std::string const& source,
2283 std::string const& destination)
2284{
2285
2286#if defined(_WIN32)
2287 WIN32_FILE_ATTRIBUTE_DATA statSource;
2288 if (GetFileAttributesExW(Encoding::ToWindowsExtendedPath(source).c_str(),
2289 GetFileExInfoStandard, &statSource) == 0) {
2290 return true;
2291 }
2292
2293 WIN32_FILE_ATTRIBUTE_DATA statDestination;
2294 if (GetFileAttributesExW(
2295 Encoding::ToWindowsExtendedPath(destination).c_str(),
2296 GetFileExInfoStandard, &statDestination) == 0) {
2297 return true;
2298 }
2299
2300 if (statSource.nFileSizeHigh != statDestination.nFileSizeHigh ||
2301 statSource.nFileSizeLow != statDestination.nFileSizeLow) {
2302 return true;
2303 }
2304
2305 if (statSource.nFileSizeHigh == 0 && statSource.nFileSizeLow == 0) {
2306 return false;
2307 }
2308 auto nleft =
2309 ((__int64)statSource.nFileSizeHigh << 32) + statSource.nFileSizeLow;
2310
2311#else
2312
2313 struct stat statSource;
2314 if (stat(source.c_str(), &statSource) != 0) {
2315 return true;
2316 }
2317
2318 struct stat statDestination;
2319 if (stat(destination.c_str(), &statDestination) != 0) {
2320 return true;
2321 }
2322
2323 if (statSource.st_size != statDestination.st_size) {
2324 return true;
2325 }
2326
2327 if (statSource.st_size == 0) {
2328 return false;
2329 }
2330 off_t nleft = statSource.st_size;
2331#endif
2332
2333#if defined(_WIN32)
2334 kwsys::ifstream finSource(source.c_str(), (std::ios::binary | std::ios::in));
2335 kwsys::ifstream finDestination(destination.c_str(),
2336 (std::ios::binary | std::ios::in));
2337#else
2338 kwsys::ifstream finSource(source.c_str());
2339 kwsys::ifstream finDestination(destination.c_str());

Callers

nothing calls this directly

Calls 3

c_strMethod · 0.80
statClass · 0.70
readMethod · 0.45

Tested by

no test coverage detected