* One dimension is existence: both sides, left only, or right only
*
* One dimension is type: directory, or file
+ *
+ * @note times in fileinfo's are seconds since January 1, 1970.
+ * See Dirscan.cpp/fentry and Dirscan.cpp/LoadFiles()
*/
struct DIFFITEM : DIFFCODE
PrediffingInfo ** infoPrediffer) = 0;
};
-
-class CDiffContext
+/**
+ * @brief Directory compare context.
+ *
+ * @note If you add new member variables, remember to copy values in
+ * CDiffContext::CDiffContext(..,CDiffContext) constructor!
+ */
+class CDiffContext
{
public:
CDiffContext(LPCTSTR pszLeft, LPCTSTR pszRight);
}
- if (pCtxt->m_nCompMethod == 0)
+ if (pCtxt->m_nCompMethod == CMP_CONTENT)
{
// use diffutils
code = diffutils_compare_files(0);
}
- else
+ else if (pCtxt->m_nCompMethod == CMP_QUICK_CONTENT)
{
// use our own byte-by-byte compare
code = byte_compare_files();
}
+ else
+ {
+ // Print error since we should have handled by date compare earlier
+ _RPTF0(_CRT_ERROR, "Invalid compare type, DiffFileData can't handle it");
+ goto exitPrepAndCompare;
+ }
if ((code & DIFFCODE::CMPERR) == 0)
{
// Static types (ie, types only used locally)
/**
* @brief directory or file info for one row in diff result
+ * @note times are seconds since January 1, 1970.
*/
struct fentry
{
CString name;
// storing __time_t if MSVC6 (__MSC_VER<1300)
// storing __time64_t if MSVC7 (VC.NET)
- __int64 mtime;
- __int64 ctime;
- _int64 size;
+ __int64 mtime; /**< Last modify time */
+ __int64 ctime; /**< Creation modify time */
+ __int64 size;
int attrs;
};
typedef CArray<fentry, fentry&> fentryArray;
nDiffCode |= DIFFCODE::SKIPPED;
StoreDiffResult(subdir, &leftFiles[i], 0, nDiffCode, pCtxt);
}
- else if (pCtxt->m_nCompMethod != 1)
+ else if (pCtxt->m_nCompMethod != CMP_DATE)
{
// Compare file to itself to detect encoding
CString filepath = sLeftDir + backslash + leftFiles[i].name;
nDiffCode |= DIFFCODE::SKIPPED;
StoreDiffResult(subdir, 0, &rightFiles[j], nDiffCode, pCtxt);
}
- else if (pCtxt->m_nCompMethod != 1)
+ else if (pCtxt->m_nCompMethod != CMP_DATE)
{
// Compare file to itself to detect encoding
CString filepath = sRightDir + backslash + rightFiles[j].name;
gLog.Write(_T("Comparing: n0=%s, n1=%s, d0=%s, d1=%s"),
leftname, rightname, (LPCTSTR)sLeftDir, (LPCTSTR)sRightDir);
- if (pCtxt->m_nCompMethod == 1)
+ if (pCtxt->m_nCompMethod == CMP_DATE)
{
// Compare only by modified date
if (leftFiles[i].mtime == rightFiles[j].mtime)
if (dwIsDirectory && StrStr(_T(".."), ff.cFileName))
continue;
fentry ent;
+ // Save filetimes as seconds since January 1, 1970
ent.ctime = CTime(ff.ftCreationTime).GetTime();
ent.mtime = CTime(ff.ftLastWriteTime).GetTime();
if (!dwIsDirectory)