diff options
Diffstat (limited to 'lib/cmp_filetime.h')
-rw-r--r-- | lib/cmp_filetime.h | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/cmp_filetime.h b/lib/cmp_filetime.h index e8cd6f50..afc97b9d 100644 --- a/lib/cmp_filetime.h +++ b/lib/cmp_filetime.h @@ -18,8 +18,8 @@ bool sameFileTime(const Int64& a, const Int64& b, size_t tolerance) //--------------------------------------------------------------------------------------------------------------- //number of seconds since Jan 1st 1970 + 1 year (needn't be too precise) -static const long oneYearFromNow = wxGetUTCTime() + 365 * 24 * 3600; //init at program startup -> avoid MT issues - +static const long oneYearFromNow = wxGetUTCTime() + 365 * 24 * 3600; //init at program startup alas in *each* compilation untit -> avoid MT issues +//refactor when C++11 thread-safe static initialization is availalbe in VS (already in GCC) class CmpFileTime { @@ -37,19 +37,16 @@ public: Result getResult(const Int64& lhs, const Int64& rhs) const { - if (lhs == rhs) + if (sameFileTime(lhs, rhs, tolerance_)) //last write time may differ by up to 2 seconds (NTFS vs FAT32) return TIME_EQUAL; - //check for erroneous dates (but only if dates are not (EXACTLY) the same) + //check for erroneous dates if (lhs < 0 || lhs > oneYearFromNow) //earlier than Jan 1st 1970 or more than one year in future return TIME_LEFT_INVALID; if (rhs < 0 || rhs > oneYearFromNow) return TIME_RIGHT_INVALID; - if (sameFileTime(lhs, rhs, tolerance_)) //last write time may differ by up to 2 seconds (NTFS vs FAT32) - return TIME_EQUAL; - //regular time comparison if (lhs < rhs) return TIME_RIGHT_NEWER; |