OSDN Git Service

PATCH: [ 698754 ] Update filetimes after save
authorKimmo Varis <kimmov@gmail.com>
Fri, 7 Mar 2003 17:48:09 +0000 (17:48 +0000)
committerKimmo Varis <kimmov@gmail.com>
Fri, 7 Mar 2003 17:48:09 +0000 (17:48 +0000)
Src/DiffContext.cpp
Src/DiffContext.h
Src/DirDoc.cpp
Src/DirDoc.h
Src/MergeDoc.cpp
Src/readme.txt

index c38762f..5655e2d 100644 (file)
@@ -154,3 +154,11 @@ void CDiffContext::UpdateStatusCode(POSITION diffpos, BYTE status)
        di.code = status;
 }
 
+void CDiffContext::UpdateTimes(POSITION diffpos, long leftTime, long rightTime)
+{
+       DIFFITEM & di = m_pList->GetAt(diffpos);
+       if (leftTime)
+               di.ltime = leftTime;
+       if (rightTime)
+               di.rtime = rightTime;
+}
index fdcd565..efb535e 100644 (file)
@@ -70,6 +70,7 @@ public:
        // change an existing difference
        void UpdateStatusCode(POSITION diffpos, BYTE status);
        void ClearStatus() { m_piStatus=0; }
+       void UpdateTimes(POSITION diffpos, long leftTime, long rightTime);
 
 
        BOOL m_bRecurse;
index 34e3a50..e6b6b7e 100644 (file)
@@ -493,17 +493,74 @@ BOOL CDirDoc::UpdateItemStatus(LPCTSTR pathLeft, LPCTSTR pathRight,
                        // Get index at view, update status to context
                        // and tell view to update found item
                        int ind = m_pView->GetItemIndex((DWORD)currentPos);
+                       current.code = (BYTE)status;
                        m_pCtxt->UpdateStatusCode(currentPos, (BYTE)status);
-                       UpdateItemStatus(ind);
+                       UpdateItemStatus(ind, current);
                        found = TRUE;
                }
                i++;
        }
        return found;
 }
+
 CDirView * CDirDoc::SetView(CDirView * newView)
 {
        CDirView * currentView = m_pView;
        m_pView = newView;
        return currentView;
 }
+
+BOOL CDirDoc::UpdateItemTimes(LPCTSTR pathLeft, LPCTSTR pathRight)
+{
+       POSITION pos = m_pCtxt->GetFirstDiffPosition();
+       POSITION currentPos;
+       DIFFITEM current;
+       int count = m_pCtxt->GetDiffCount();
+       int i = 0;
+       BOOL found = FALSE;
+
+       CString path1, file1;
+       SplitFilename(pathLeft, &path1, &file1, 0);
+       CString path2, file2;
+       SplitFilename(pathRight, &path2, &file2, 0);
+
+       // Filenames must be identical
+       if (file1 != file2)
+               return FALSE;
+
+       // Path can contain (because of difftools?) '/' and '\'
+       // so for comparing purposes, convert whole path to use '\\'
+       path1.Replace('/', '\\');
+       path2.Replace('/', '\\');
+
+       // Get first item
+       current = m_pCtxt->GetDiffAt(pos);
+
+       while (i < count && found == FALSE)
+       {
+               // Save our current pos before getting next
+               currentPos = pos;
+               current = m_pCtxt->GetNextDiffPosition( pos );
+
+               // Path can contain (because of difftools?) '/' and '\'
+               // so for comparing purposes, convert whole path to use '\'
+               current.srpath.Replace('/', '\\');
+               current.slpath.Replace('/', '\\');
+
+               if (path1 == current.slpath &&
+                       path2 == current.srpath &&
+                       file1 == current.sfilename)
+               {
+                       // Right item found!
+                       // Get index at view, update filetimes to context
+                       // and tell view to update found item
+                       int ind = m_pView->GetItemIndex((DWORD) currentPos);
+                       UpdateTimes(&current);
+                       m_pCtxt->UpdateTimes(currentPos, current.ltime, current.rtime);
+                       UpdateItemStatus(ind, current);
+                       found = TRUE;
+               }
+               i++;
+       }
+       return found;
+}
index 5f9b224..bf7db88 100644 (file)
@@ -55,6 +55,7 @@ public:
 
 // Implementation
 public:
+       BOOL UpdateItemTimes(LPCTSTR pathLeft, LPCTSTR pathRight);
        BOOL UpdateItemStatus( LPCTSTR pathLeft, LPCTSTR pathRight, UINT status );
        void SetDiffContext(CDiffContext *pCtxt);
        void UpdateResources();
index cfc41e9..199b9a6 100644 (file)
@@ -1171,8 +1171,11 @@ void CMergeDoc::OnFileSave()
        if ((bLModified && bLSaveSuccess) || 
                (bRModified && bRSaveSuccess))
        {
-               if (m_nDiffs == 0 && mf->m_pDirDoc)
+               if (mf->m_pDirDoc)
                {
+                       mf->m_pDirDoc->UpdateItemTimes(m_strLeftFile,
+                               m_strRightFile);
+                       if (m_nDiffs == 0)
                                mf->m_pDirDoc->UpdateItemStatus(m_strLeftFile,
                                        m_strRightFile, FILE_SAME);
                }
@@ -1388,8 +1391,11 @@ BOOL CMergeDoc::SaveHelper()
        if ((bLModified && bLSaveSuccess) ||
                 (bRModified && bRSaveSuccess))
        {
-               if (m_nDiffs == 0 && mf->m_pDirDoc)
+               if (mf->m_pDirDoc)
                {
+                       mf->m_pDirDoc->UpdateItemTimes(m_strLeftFile,
+                               m_strRightFile);
+                       if (m_nDiffs == 0)
                        mf->m_pDirDoc->UpdateItemStatus(m_strLeftFile,
                                m_strRightFile, FILE_SAME);
                }
index e446e06..8222045 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-07 Kimmo
+ PATCH: [ 698754 ] Update filetimes after save
+  WinMerge: DiffContext.h DiffContext.cpp DirDoc.h DirDoc.cpp MergeDoc.cpp
+
 2003-03-06 Christian
  Update Danish language file with new strings in MergeDanish.rc
  Removed duplicate dialog in French language file in MergeFrench.rc