FIX: fix UMR
This commit is contained in:
parent
ea7888c11b
commit
4307df12ac
@ -957,28 +957,52 @@ bool cmSystemTools::FilesDiffer(const char* source,
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stat statDestination;
|
struct stat statDestination;
|
||||||
if (stat(destination, &statDestination) != 0)
|
if (stat(destination, &statDestination) != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(statSource.st_size != statDestination.st_size)
|
if(statSource.st_size != statDestination.st_size)
|
||||||
{
|
{
|
||||||
return true;
|
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 finSource(source);
|
||||||
std::ifstream finDestination(destination);
|
std::ifstream finDestination(destination);
|
||||||
|
#endif
|
||||||
if(!finSource || !finDestination)
|
if(!finSource || !finDestination)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
char* buffer1 = new char[statSource.st_size];
|
|
||||||
char* buffer2 = new char[statSource.st_size];
|
char* source_buf = new char[statSource.st_size];
|
||||||
finSource.read(buffer1, statSource.st_size);
|
char* dest_buf = new char[statSource.st_size];
|
||||||
finDestination.read(buffer2, statSource.st_size);
|
|
||||||
int ret = memcmp(buffer1, buffer2, statSource.st_size);
|
finSource.read(source_buf, statSource.st_size);
|
||||||
delete [] buffer2;
|
finDestination.read(dest_buf, statSource.st_size);
|
||||||
delete [] buffer1;
|
|
||||||
|
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;
|
return ret != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user