From 8d5213662f2870354015ca4a3dbb966d25c52bc2 Mon Sep 17 00:00:00 2001 From: Brad King <brad.king@kitware.com> Date: Thu, 3 Jun 2010 12:46:11 -0400 Subject: [PATCH] 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. --- SystemTools.cxx | 14 +------------- kwsysDateStamp.cmake | 4 ++-- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/SystemTools.cxx b/SystemTools.cxx index afc7240..a2e194a 100644 --- a/SystemTools.cxx +++ b/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) ) diff --git a/kwsysDateStamp.cmake b/kwsysDateStamp.cmake index 8fd851f..09a6912 100644 --- a/kwsysDateStamp.cmake +++ b/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2010) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 05) +SET(KWSYS_DATE_STAMP_MONTH 06) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 12) +SET(KWSYS_DATE_STAMP_DAY 03) -- GitLab