From c15ed3294c68cc819d9471c4ea41dc3d2a95aadd Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Jun 2010 12:46:11 -0400 Subject: 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. --- Source/kwsys/SystemTools.cxx | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index afc7240..a2e194a 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1924,22 +1924,10 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination, fin.close(); fout.close(); - // More checks. - 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) + if(!fout) { return false; } - else if(statSource.st_size != statDestination.st_size) - { - return false; - } if ( copyPermissions && perms ) { if ( !SystemTools::SetPermissions(destination, perm) ) -- cgit v0.12