OSDN Git Service

Task #21516: Added file modification times to directory view
authorgrimmd <none@none>
Wed, 21 Feb 2001 06:39:02 +0000 (06:39 +0000)
committergrimmd <none@none>
Wed, 21 Feb 2001 06:39:02 +0000 (06:39 +0000)
Src/Diff.cpp
Src/DiffContext.cpp
Src/DiffContext.h
Src/DirDoc.cpp
Src/DirView.cpp
Src/DirView.h
Src/Merge.rc
Src/OpenDlg.cpp
Src/resource.h

index 7406ccf..68289ad 100644 (file)
@@ -297,7 +297,7 @@ compare_files (LPCTSTR dir0, LPCTSTR name0,
                          code = FILE_RUNIQUE;
                  name = name1;
          }
-         pCtx->AddDiff(name, dir0, dir1, code);
+         pCtx->AddDiff(name, dir0, dir1, inf[0].stat.st_mtime, inf[1].stat.st_mtime, code);
       if (gWriteLog) gLog.Write(_T("\tUnique\r\n"));
          if (free0)
                  free (free0);
@@ -337,7 +337,7 @@ compare_files (LPCTSTR dir0, LPCTSTR name0,
       /* If either file should exist but does not, return 2.  */
 
       val = 2;
-      pCtx->AddDiff(name0, dir0, dir1, FILE_ERROR);
+      pCtx->AddDiff(name0, dir0, dir1, 0, 0, FILE_ERROR);
     }
 #if defined(__MSDOS__) || defined(__NT__) || defined(WIN32)
   else if (same_files = 0) /* yes, only ONE equal sign intended! hmo11apr93 */
@@ -354,7 +354,7 @@ compare_files (LPCTSTR dir0, LPCTSTR name0,
         We know they are identical without actually reading them.  */
 
       val = 0;
-      pCtx->AddDiff(name0, dir0, dir0, FILE_SAME);
+      pCtx->AddDiff(name0, dir0, dir0, inf[0].stat.st_mtime, inf[1].stat.st_mtime, FILE_SAME);
     }
 #endif /*__MSDOS__||__NT__*/
   else if (inf[0].dir_p & inf[1].dir_p)
@@ -419,7 +419,7 @@ compare_files (LPCTSTR dir0, LPCTSTR name0,
 
          /* This is a difference.  */
          val = 1;
-         pCtx->AddDiff(name0, dir0, dir1, FILE_DIFF);
+         pCtx->AddDiff(name0, dir0, dir1, inf[0].stat.st_mtime, inf[1].stat.st_mtime, FILE_DIFF);
        }
     }
   else if ((no_details_flag & ~ignore_some_changes)
@@ -429,7 +429,7 @@ compare_files (LPCTSTR dir0, LPCTSTR name0,
     {
       message ("Files %s and %s differ\n", inf[0].name, inf[1].name);
       val = 1;
-      pCtx->AddDiff(name0, dir0, dir1, FILE_DIFF);
+      pCtx->AddDiff(name0, dir0, dir1, inf[0].stat.st_mtime, inf[1].stat.st_mtime, FILE_DIFF);
     }
   else
     {
@@ -485,19 +485,19 @@ compare_files (LPCTSTR dir0, LPCTSTR name0,
 
                if(val==2)
            {
-                       pCtx->AddDiff(name0, dir0, dir1, FILE_ERROR);
+                       pCtx->AddDiff(name0, dir0, dir1, inf[0].stat.st_mtime, inf[1].stat.st_mtime, FILE_ERROR);
                        if (gWriteLog) gLog.Write(_T("\t%s.\r\n"), val==2? "error":"different");
            }
                else if (diff_flag)
            {
                        val = 1;
-                       pCtx->AddDiff(name0, dir0, dir1, FILE_BINDIFF);
+                       pCtx->AddDiff(name0, dir0, dir1, inf[0].stat.st_mtime, inf[1].stat.st_mtime, FILE_BINDIFF);
                                if (gWriteLog) gLog.Write(_T("\tbinary.\r\n"));
            }
            else 
            {
                        val = 0;
-                       //pCtx->AddDiff(name0, dir0, dir1, FILE_SAME);
+                       //pCtx->AddDiff(name0, dir0, dir1, inf[0].stat.st_mtime, inf[1].stat.st_mtime, FILE_SAME);
                        //      if (gWriteLog) gLog.Write(_T("\tidentical.\r\n"));
            }
        }
@@ -531,7 +531,7 @@ compare_files (LPCTSTR dir0, LPCTSTR name0,
            }
            if (val==2 || val == 1)
            {
-               pCtx->AddDiff(name0, dir0, dir1, (BYTE)(val==2? FILE_ERROR:FILE_DIFF));
+               pCtx->AddDiff(name0, dir0, dir1, inf[0].stat.st_mtime, inf[1].stat.st_mtime, (BYTE)(val==2? FILE_ERROR:FILE_DIFF));
                if (gWriteLog) gLog.Write(_T("\t%s.\r\n"), val==2? "error":"different");
            }
        }
@@ -545,7 +545,7 @@ compare_files (LPCTSTR dir0, LPCTSTR name0,
       if (print_file_same_flag)
        message ("Files %s and %s are identical\n",
                 inf[0].name, inf[1].name);
-      pCtx->AddDiff(name0, dir0, dir1, FILE_SAME);
+      pCtx->AddDiff(name0, dir0, dir1, inf[0].stat.st_mtime, inf[1].stat.st_mtime, FILE_SAME);
       if (gWriteLog) gLog.Write(_T("\tidentical.\r\n"));
    }
   else
index a4840db..356a7f6 100644 (file)
@@ -68,12 +68,15 @@ CDiffContext::~CDiffContext()
 }
        
 
-void CDiffContext::AddDiff(LPCTSTR pszFilename, LPCTSTR pszLeftDir, LPCTSTR pszRightDir, BYTE code)
+void CDiffContext::AddDiff(LPCTSTR pszFilename, LPCTSTR pszLeftDir, LPCTSTR pszRightDir, 
+                                                  long ltime, long rtime, BYTE code)
 {
        DIFFITEM di;
        strcpy(di.filename,pszFilename);
        strcpy(di.lpath, pszLeftDir);
        strcpy(di.rpath, pszRightDir);
+       di.ltime = ltime;
+       di.rtime = rtime;
        di.code = code;
        m_pList->AddTail(di);
 }
index d5f9c42..eb870d0 100644 (file)
@@ -20,6 +20,7 @@ struct dirdata
 typedef struct tagDIFFITEM {
        TCHAR filename[_MAX_FNAME+_MAX_EXT];
        TCHAR lpath[MAX_PATH], rpath[MAX_PATH];
+       long ltime, rtime;
        BYTE code;
 }DIFFITEM;
 
@@ -36,7 +37,7 @@ class CDiffContext
 {
 public:
        void SetRegExp(LPCTSTR pszExp);
-       void AddDiff(LPCTSTR pszFilename, LPCTSTR pszLeftDir, LPCTSTR pszRightDir, BYTE code);
+       void AddDiff(LPCTSTR pszFilename, LPCTSTR pszLeftDir, LPCTSTR pszRightDir, long ltime, long rtime, BYTE code);
        CDiffContext(LPCTSTR pszLeft = NULL, LPCTSTR pszRight = NULL);
        CDiffContext(LPCTSTR pszLeft, LPCTSTR pszRight, CDiffContext& src);
        virtual ~CDiffContext();
index 0dd4c87..503408b 100644 (file)
@@ -325,39 +325,68 @@ void CDirDoc::UpdateItemStatus(UINT nIdx)
        int rlen = m_pCtxt->m_strRight.GetLength();
        POSITION pos = (POSITION)m_pView->m_pList->GetItemData(nIdx);
        DIFFITEM di = m_pCtxt->m_dirlist.GetAt(pos);
+       TCHAR sTime[80];
        switch (di.code)
        {
        case FILE_DIFF:
                VERIFY(s.LoadString(IDS_FILES_ARE_DIFFERENT));
                m_pView->AddItem(nIdx, DV_STATUS, s);
                m_pView->SetImage(nIdx, FILE_DIFF);
+               _tcsftime(sTime, 80, _T("%c"), localtime(&di.ltime));
+               m_pView->AddItem(nIdx, DV_LTIME, sTime);
+               _tcsftime(sTime, 80, _T("%c"), localtime(&di.rtime));
+               m_pView->AddItem(nIdx, DV_RTIME, sTime);
                break;
        case FILE_BINDIFF:
                VERIFY(s.LoadString(IDS_BIN_FILES_DIFF));
                m_pView->AddItem(nIdx, DV_STATUS, s);
                m_pView->SetImage(nIdx, FILE_BINDIFF);
+               _tcsftime(sTime, 80, _T("%c"), localtime(&di.ltime));
+               m_pView->AddItem(nIdx, DV_LTIME, sTime);
+               _tcsftime(sTime, 80, _T("%c"), localtime(&di.rtime));
+               m_pView->AddItem(nIdx, DV_RTIME, sTime);
                break;
        case FILE_LUNIQUE:
        case FILE_LDIRUNIQUE:
                AfxFormatString1(s, IDS_ONLY_IN_FMT, di.lpath);
                m_pView->AddItem(nIdx, DV_STATUS, s);
                m_pView->SetImage(nIdx, di.code);
+               _tcsftime(sTime, 80, _T("%c"), localtime(&di.ltime));
+               m_pView->AddItem(nIdx, DV_LTIME, sTime);
+               m_pView->AddItem(nIdx, DV_RTIME, _T("---"));
                break;
        case FILE_RUNIQUE:
        case FILE_RDIRUNIQUE:
                AfxFormatString1(s, IDS_ONLY_IN_FMT, di.rpath);
                m_pView->AddItem(nIdx, DV_STATUS, s);
                m_pView->SetImage(nIdx, di.code);
+               m_pView->AddItem(nIdx, DV_LTIME, _T("---"));
+               _tcsftime(sTime, 80, _T("%c"), localtime(&di.rtime));
+               m_pView->AddItem(nIdx, DV_RTIME, sTime);
                break;
        case FILE_SAME:
                VERIFY(s.LoadString(IDS_IDENTICAL));
                m_pView->AddItem(nIdx, DV_STATUS,s);
                m_pView->SetImage(nIdx, FILE_SAME);
+               _tcsftime(sTime, 80, _T("%c"), localtime(&di.ltime));
+               m_pView->AddItem(nIdx, DV_LTIME, sTime);
+               _tcsftime(sTime, 80, _T("%c"), localtime(&di.rtime));
+               m_pView->AddItem(nIdx, DV_RTIME, sTime);
                break;
        default: // error
                VERIFY(s.LoadString(IDS_CANT_COMPARE_FILES));
                m_pView->AddItem(nIdx, DV_STATUS, s);
                m_pView->SetImage(nIdx, FILE_ERROR);
+               if (di.ltime>0)
+                       _tcsftime(sTime, 80, _T("%c"), localtime(&di.ltime));
+               else
+                       *sTime = _T('\0');
+               m_pView->AddItem(nIdx, DV_LTIME, sTime);
+               if (di.rtime>0)
+                       _tcsftime(sTime, 80, _T("%c"), localtime(&di.rtime));
+               else
+                       *sTime = _T('\0');
+               m_pView->AddItem(nIdx, DV_RTIME, sTime);
                break;
        }
 }
index 0957e30..be71739 100644 (file)
@@ -108,6 +108,8 @@ void CDirView::OnInitialUpdate()
        m_pList->InsertColumn(DV_NAME, _T("Filename"), LVCFMT_LEFT, 150);
        m_pList->InsertColumn(DV_PATH, _T("Directory"), LVCFMT_LEFT, 200);
        m_pList->InsertColumn(DV_STATUS, _T("Comparison result"), LVCFMT_LEFT, 250);
+       m_pList->InsertColumn(DV_LTIME, _T("Left Time"), LVCFMT_LEFT, 150);
+       m_pList->InsertColumn(DV_RTIME, _T("Right Time"), LVCFMT_LEFT, 150);
 
        CBitmap bm;
        VERIFY (m_imageList.Create (16, 16, ILC_MASK, 0, 1));
@@ -403,6 +405,12 @@ void CDirView::UpdateResources()
        VERIFY(s.LoadString(IDS_RESULT_HEADER));
        lvc.pszText = (LPTSTR)((LPCTSTR)s);
        m_pList->SetColumn(DV_STATUS, &lvc);
+       VERIFY(s.LoadString(IDS_LTIME_HEADER));
+       lvc.pszText = (LPTSTR)((LPCTSTR)s);
+       m_pList->SetColumn(DV_LTIME, &lvc);
+       VERIFY(s.LoadString(IDS_RTIME_HEADER));
+       lvc.pszText = (LPTSTR)((LPCTSTR)s);
+       m_pList->SetColumn(DV_RTIME, &lvc);
 }
 
 BOOL CDirView::GetSelectedDirNames(CString& strLeft, CString& strRight)
@@ -441,6 +449,12 @@ int CALLBACK CDirView::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParam
        case DV_STATUS: // Diff Status.
                retVal = rDi.code-lDi.code;
                break;
+       case DV_LTIME: // Diff Status.
+               retVal = rDi.ltime-lDi.ltime;
+               break;
+       case DV_RTIME: // Diff Status.
+               retVal = lDi.rtime-rDi.rtime;
+               break;
        }
        // return compare result, considering sort direction
        return (pView->m_bSortAscending)?retVal:-retVal;
index e9e7657..4b25858 100644 (file)
@@ -29,6 +29,8 @@
 #define DV_NAME   0
 #define DV_PATH   1
 #define DV_STATUS 2
+#define DV_LTIME 3
+#define DV_RTIME 4
 
 /////////////////////////////////////////////////////////////////////////////
 // CDirView view
index a227fa7..f373698 100644 (file)
@@ -859,6 +859,8 @@ BEGIN
     IDS_VSS_RUN_ERROR       "Error executing versioning system command."
     IDS_DIFF_OPEN_NO_SET_PROPS 
                             "Modifications have been made to the current file comparison session.  Some property settings may not take place until the current file comparison is restarted."
+    IDS_LTIME_HEADER        "Left Date"
+    IDS_RTIME_HEADER        "Right Date"
 END
 
 #endif    // English (U.S.) resources
index c953353..445c49b 100644 (file)
@@ -67,7 +67,7 @@ void COpenDlg::DoDataExchange(CDataExchange* pDX)
        DDX_CBStringExact(pDX, IDC_LEFT_COMBO, m_strLeft);
        DDX_CBStringExact(pDX, IDC_RIGHT_COMBO, m_strRight);
        DDX_Check(pDX, IDC_RECURS_CHECK, m_bRecurse);
-       DDX_CBString(pDX, IDC_EXT_COMBO, m_strExt);
+       DDX_CBStringExact(pDX, IDC_EXT_COMBO, m_strExt);
        //}}AFX_DATA_MAP
 }
 
index 4249298..1465be4 100644 (file)
@@ -63,6 +63,8 @@
 #define IDS_VSS_CMD                     168
 #define IDS_VSS_RUN_ERROR               169
 #define IDS_DIFF_OPEN_NO_SET_PROPS      170
+#define IDS_LTIME_HEADER                171
+#define IDS_RTIME_HEADER                172
 #define IDB_EQUAL                       213
 #define IDB_NOTEQUAL                    214
 #define IDB_RFOLDER                     215