summaryrefslogtreecommitdiff
path: root/lib/cmp_filetime.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:15:39 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:15:39 +0200
commitd2854834e18443876c8f75e0a7f3b88d1d549fc4 (patch)
treee967b628081e50abc7c34cd264e6586271c7e728 /lib/cmp_filetime.h
parent4.1 (diff)
downloadFreeFileSync-d2854834e18443876c8f75e0a7f3b88d1d549fc4.tar.gz
FreeFileSync-d2854834e18443876c8f75e0a7f3b88d1d549fc4.tar.bz2
FreeFileSync-d2854834e18443876c8f75e0a7f3b88d1d549fc4.zip
4.2
Diffstat (limited to 'lib/cmp_filetime.h')
-rw-r--r--lib/cmp_filetime.h11
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;
bgstack15