Permalink
@@ -550,7 +550,7 @@ void CHexMergeDoc::CheckFileChanged(void)
{
for (int pane = 0 ; pane < m_nBuffers; ++pane)
{
if (m_pView[pane]->IsFileChangedOnDisk (m_filePaths[pane].c_str ()))
if (m_pView[pane]->IsFileChangedOnDisk (m_filePaths[pane].c_str ()) == FileChanged )
{
String msg = strutils::format_string1 (_ (" Another application has updated file\n %1\n since WinMerge scanned it last time.\n\n Do you want to reload the file?" ), m_filePaths[pane]);
if (AfxMessageBox (msg.c_str (), MB_YESNO | MB_ICONWARNING) == IDYES)
@@ -732,7 +732,8 @@ void CHexMergeDoc::OnFileReload()
fileloc[pane].setPath (m_filePaths[pane]);
bRO[pane] = m_pView[pane]->GetReadOnly ();
}
OpenDocs (m_nBuffers, fileloc, bRO, m_strDesc);
if (!OpenDocs (m_nBuffers, fileloc, bRO, m_strDesc))
return ;
MoveOnLoad (GetActiveMergeView ()->m_nThisPane );
}
@@ -246,18 +246,19 @@ int CHexMergeView::GetLength()
* @param [in] path File to check
* @return `true` if file is changed.
*/
bool CHexMergeView::IsFileChangedOnDisk (LPCTSTR path)
IMergeDoc::FileChange CHexMergeView::IsFileChangedOnDisk (LPCTSTR path)
{
DiffFileInfo dfi;
dfi.Update (path);
if (!dfi.Update (path))
return IMergeDoc::FileRemoved;
int tolerance = 0 ;
if (GetOptionsMgr ()->GetBool (OPT_IGNORE_SMALL_FILETIME))
tolerance = SmallTimeDiff; // From MainFrm.h
int64_t timeDiff = dfi.mtime - m_fileInfo.mtime ;
if (timeDiff < 0 ) timeDiff = -timeDiff;
if ((timeDiff > tolerance * Poco::Timestamp::resolution ()) || (dfi.size != m_fileInfo.size ))
return true ;
return false ;
return IMergeDoc::FileChanged ;
return IMergeDoc::FileNoChange ;
}
/* *
@@ -298,7 +299,7 @@ HRESULT CHexMergeView::LoadFile(LPCTSTR path)
HRESULT CHexMergeView::SaveFile (LPCTSTR path)
{
// Warn user in case file has been changed by someone else
if (IsFileChangedOnDisk (path))
if (IsFileChangedOnDisk (path) == IMergeDoc::FileChanged )
{
String msg = strutils::format_string1 (_ (" Another application has updated file\n %1\n since WinMerge loaded it.\n\n Overwrite changed file?" ), path);
if (AfxMessageBox (msg.c_str (), MB_ICONWARNING | MB_YESNO) == IDNO)
@@ -25,6 +25,7 @@
#pragma once
#include " DiffFileInfo.h"
#include " IMergeDoc.h"
class CHexMergeDoc ;
class IHexEditorWindow ;
@@ -55,7 +56,7 @@ class CHexMergeView : public CView
bool GetReadOnly ();
void SetReadOnly (bool );
void ResizeWindow ();
bool IsFileChangedOnDisk (LPCTSTR);
IMergeDoc::FileChange IsFileChangedOnDisk (LPCTSTR);
void ZoomText (int amount);
static void CopySel (const CHexMergeView *src, CHexMergeView *dst);
static void CopyAll (const CHexMergeView *src, CHexMergeView *dst);
@@ -6,6 +6,13 @@ class CDirDoc;
struct IMergeDoc
{
enum FileChange
{
FileNoChange,
FileChanged,
FileRemoved,
};
virtual void SetDirDoc (CDirDoc *pDirDoc) = 0;
virtual bool CloseNow (void ) = 0;
virtual bool GenerateReport (const String &path) const = 0;
@@ -304,25 +304,26 @@ void CImgMergeFrame::SetDirDoc(CDirDoc * pDirDoc)
m_pDirDoc = pDirDoc;
}
bool CImgMergeFrame::IsFileChangedOnDisk (int pane) const
IMergeDoc::FileChange CImgMergeFrame::IsFileChangedOnDisk (int pane) const
{
DiffFileInfo dfi;
dfi.Update (m_filePaths[pane]);
if (!dfi.Update (m_filePaths[pane]))
return FileRemoved;
int tolerance = 0 ;
if (GetOptionsMgr ()->GetBool (OPT_IGNORE_SMALL_FILETIME))
tolerance = SmallTimeDiff; // From MainFrm.h
int64_t timeDiff = dfi.mtime - m_fileInfo[pane].mtime ;
if (timeDiff < 0 ) timeDiff = -timeDiff;
if ((timeDiff > tolerance * Poco::Timestamp::resolution ()) || (dfi.size != m_fileInfo[pane].size ))
return true ;
return false ;
return FileChanged ;
return FileNoChange ;
}
void CImgMergeFrame::CheckFileChanged (void )
{
for (int pane = 0 ; pane < m_pImgMergeWindow->GetPaneCount (); ++pane)
{
if (IsFileChangedOnDisk (pane))
if (IsFileChangedOnDisk (pane) == FileChanged )
{
String msg = strutils::format_string1 (_ (" Another application has updated file\n %1\n since WinMerge scanned it last time.\n\n Do you want to reload the file?" ), m_filePaths[pane]);
if (AfxMessageBox (msg.c_str (), MB_YESNO | MB_ICONWARNING) == IDYES)
@@ -72,7 +72,7 @@ class CImgMergeFrame : public CMergeFrameCommon,public IMergeDoc
bool GenerateReport (const String& sFileName ) const override ;
void DoAutoMerge (int dstPane);
bool IsModified () const ;
bool IsFileChangedOnDisk (int pane) const ;
IMergeDoc::FileChange IsFileChangedOnDisk (int pane) const ;
void CheckFileChanged (void ) override ;
String GetDescription (int pane) const { return m_strDesc[pane]; }
static bool IsLoadable ();
@@ -140,13 +140,6 @@ class CLocationView;
class CMergeDoc : public CDocument , public IMergeDoc
{
public:
enum FileChange
{
FileNoChange,
FileChanged,
FileRemoved,
};
// Attributes
public:
static int m_nBuffersTemp;
Toggle all file notes
0 comments on commit
9c16ef8