KWSys: Avoid stat in CopyFileAlways (#10790)
On Windows 7 the file size reported by 'stat' on a new file sometimes reports zero even though the real size is correct. This causes our CopyFileAlways method to falsely detect copy failure. Work around the problem by trusting the state of ofstream after writing the file.
This commit is contained in:
parent
3ac3dea6f0
commit
c15ed3294c
|
@ -1924,19 +1924,7 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination,
|
||||||
fin.close();
|
fin.close();
|
||||||
fout.close();
|
fout.close();
|
||||||
|
|
||||||
// More checks.
|
if(!fout)
|
||||||
struct stat statSource, statDestination;
|
|
||||||
statSource.st_size = 12345;
|
|
||||||
statDestination.st_size = 12345;
|
|
||||||
if(stat(source, &statSource) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if(stat(destination, &statDestination) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if(statSource.st_size != statDestination.st_size)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue