diff options
author | Sebastien Barre <sebastien.barre@kitware.com> | 2002-04-12 13:57:17 (GMT) |
---|---|---|
committer | Sebastien Barre <sebastien.barre@kitware.com> | 2002-04-12 13:57:17 (GMT) |
commit | 4307df12ac97a9eca56593aea9871d094fa506f6 (patch) | |
tree | 96413a3fd07169156ebe5a5f521ea2f96661390b /Source/cmSystemTools.cxx | |
parent | ea7888c11b8ba2a1940228eae4b87aa0dbaf7055 (diff) | |
download | CMake-4307df12ac97a9eca56593aea9871d094fa506f6.zip CMake-4307df12ac97a9eca56593aea9871d094fa506f6.tar.gz CMake-4307df12ac97a9eca56593aea9871d094fa506f6.tar.bz2 |
FIX: fix UMR
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index bb0a86b..fb540bc 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -957,28 +957,52 @@ bool cmSystemTools::FilesDiffer(const char* source, { return true; } + struct stat statDestination; if (stat(destination, &statDestination) != 0) { return true; } + if(statSource.st_size != statDestination.st_size) { return true; } + +#ifdef _WIN32 + std::ifstream finSource(source, std::ios::binary | std::ios::in); + std::ifstream finDestination(destination, std::ios::binary | std::ios::in); +#else std::ifstream finSource(source); std::ifstream finDestination(destination); +#endif if(!finSource || !finDestination) { return true; } - char* buffer1 = new char[statSource.st_size]; - char* buffer2 = new char[statSource.st_size]; - finSource.read(buffer1, statSource.st_size); - finDestination.read(buffer2, statSource.st_size); - int ret = memcmp(buffer1, buffer2, statSource.st_size); - delete [] buffer2; - delete [] buffer1; + + char* source_buf = new char[statSource.st_size]; + char* dest_buf = new char[statSource.st_size]; + + finSource.read(source_buf, statSource.st_size); + finDestination.read(dest_buf, statSource.st_size); + + if(statSource.st_size != finSource.gcount() || + statSource.st_size != finDestination.gcount()) + { + cmSystemTools::Error("FilesDiffer failed reading files!"); + delete [] dest_buf; + delete [] source_buf; + return false; + } + + int ret = memcmp((const void*)source_buf, + (const void*)dest_buf, + statSource.st_size); + + delete [] dest_buf; + delete [] source_buf; + return ret != 0; } |