OSDN Git Service

PATCH: #2919510 TimeSizecompare
authorKimmo Varis <kimmov@gmail.com>
Tue, 4 May 2010 18:11:48 +0000 (18:11 +0000)
committerKimmo Varis <kimmov@gmail.com>
Tue, 4 May 2010 18:11:48 +0000 (18:11 +0000)
 Submitted by Matthias Mayer
 Comparing files by size also always compared by time.

Docs/Users/ChangeLog.txt
Src/CompareEngines/TimeSizeCompare.cpp

index 4895ad2..cbfda6a 100644 (file)
@@ -6,6 +6,7 @@ http://winmerge.org/tracker/[tracker-id]
 WinMerge 2.13.13
   Installer: Embed MS runtime files installer for x64 (r7150)
   Allow DOS-style pattern matching in Open-dialog filters (#2988369)
+  Bugfix: Compare by size always checked file times too (#2919510)
 
 WinMerge 2.13.12 - 2010-04-29 (r7148)
   Update copyright year to 2010
index d92716a..9a72dd2 100644 (file)
@@ -40,40 +40,39 @@ void TimeSizeCompare::SetAdditionalOptions(bool ignoreSmallDiff)
  */
 int TimeSizeCompare::CompareFiles(int compMethod, const DIFFITEM &di)
 {
-       UINT code = 0;
-
-       // Compare by modified date
-       // Check that we have both filetimes
-       if (di.left.mtime != 0 && di.right.mtime != 0)
+       UINT code = DIFFCODE::SAME;
+       if ((compMethod == CMP_DATE) || (compMethod == CMP_DATE_SIZE))
        {
-               INT64 nTimeDiff = di.left.mtime - di.right.mtime;
-               // Remove sign
-               nTimeDiff = (nTimeDiff > 0 ? nTimeDiff : -nTimeDiff);
-               if (m_ignoreSmallDiff)
+               // Compare by modified date
+               // Check that we have both filetimes
+               if (di.left.mtime != 0 && di.right.mtime != 0)
                {
-                       // If option to ignore small timediffs (couple of seconds)
-                       // is set, decrease absolute difference by allowed diff
-                       nTimeDiff -= SmallTimeDiff;
+                       INT64 nTimeDiff =_abs64(di.left.mtime - di.right.mtime);
+                       if (m_ignoreSmallDiff)
+                       {
+                               // If option to ignore small timediffs (couple of seconds)
+                               // is set, decrease absolute difference by allowed diff
+                               nTimeDiff -= SmallTimeDiff;
+                       }
+                       if (nTimeDiff <= 0)
+                               code = DIFFCODE::SAME;
+                       else
+                               code = DIFFCODE::DIFF;
                }
-               if (nTimeDiff <= 0)
-                       code = DIFFCODE::SAME;
-               else
-                       code = DIFFCODE::DIFF;
-       }
-       else
-       {
-               // Filetimes for item(s) could not be read. So we have to
-               // set error status, unless we have DATE_SIZE -compare
-               // when we have still hope for size compare..
-               if (compMethod == CMP_DATE_SIZE)
-                       code = DIFFCODE::SAME;
                else
-                       code = DIFFCODE::CMPERR;
+               {
+                       // Filetimes for item(s) could not be read. So we have to
+                       // set error status, unless we have DATE_SIZE -compare
+                       // when we have still hope for size compare..
+                       if (compMethod == CMP_DATE_SIZE)
+                               code = DIFFCODE::SAME;
+                       else
+                               code = DIFFCODE::CMPERR;
+               }
        }
-
-       // This is actual CMP_DATE_SIZE method..
+       // This is actual CMP_SIZE method..
        // If file sizes differ mark them different
-       if (compMethod == CMP_DATE_SIZE)
+       if ((compMethod == CMP_DATE_SIZE) || (compMethod == CMP_SIZE))
        {
                if (di.left.size != di.right.size)
                {