From: Kimmo Varis Date: Fri, 7 Mar 2003 17:48:09 +0000 (+0000) Subject: PATCH: [ 698754 ] Update filetimes after save X-Git-Tag: 2.16.5~8090 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=20692f8e8cf3fc3e3a1f17b10429a14ae63dfa88;p=winmerge-jp%2Fwinmerge-jp.git PATCH: [ 698754 ] Update filetimes after save --- diff --git a/Src/DiffContext.cpp b/Src/DiffContext.cpp index c38762f37..5655e2db9 100644 --- a/Src/DiffContext.cpp +++ b/Src/DiffContext.cpp @@ -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; +} diff --git a/Src/DiffContext.h b/Src/DiffContext.h index fdcd565bf..efb535e35 100644 --- a/Src/DiffContext.h +++ b/Src/DiffContext.h @@ -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; diff --git a/Src/DirDoc.cpp b/Src/DirDoc.cpp index 34e3a5060..e6b6b7e38 100644 --- a/Src/DirDoc.cpp +++ b/Src/DirDoc.cpp @@ -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(¤t); + m_pCtxt->UpdateTimes(currentPos, current.ltime, current.rtime); + UpdateItemStatus(ind, current); + found = TRUE; + } + i++; + } + return found; +} diff --git a/Src/DirDoc.h b/Src/DirDoc.h index 5f9b22482..bf7db8876 100644 --- a/Src/DirDoc.h +++ b/Src/DirDoc.h @@ -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(); diff --git a/Src/MergeDoc.cpp b/Src/MergeDoc.cpp index cfc41e969..199b9a681 100644 --- a/Src/MergeDoc.cpp +++ b/Src/MergeDoc.cpp @@ -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); } diff --git a/Src/readme.txt b/Src/readme.txt index e446e06dc..8222045b7 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -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