OSDN Git Service

PATCH: [ 1376711 ] Change CFile::GetStatus to paths_DoesPathExist
authorPerry Rapp <elsapo@users.sourceforge.net>
Sat, 17 Dec 2005 04:49:05 +0000 (04:49 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Sat, 17 Dec 2005 04:49:05 +0000 (04:49 +0000)
  Src: files.cpp MainFrm.cpp MainFrm.h Merge.cpp MergeDoc.cpp OpenDlg.cpp
   PathContext.cpp
  Src/Common: coretools.cpp

Src/Changes.txt
Src/Common/coretools.cpp
Src/MainFrm.cpp
Src/MainFrm.h
Src/Merge.cpp
Src/MergeDoc.cpp
Src/OpenDlg.cpp
Src/PathContext.cpp

index 3851cba..a53ef5f 100644 (file)
@@ -1,6 +1,10 @@
 2005-12-17 Perry
  PATCH: [ 1382955 ] Remove unused CompareStats.h include from DirFrame.cpp
   Src: DirFrame.cpp
+ PATCH: [ 1376711 ] Change CFile::GetStatus to paths_DoesPathExist
+  Src: files.cpp MainFrm.cpp MainFrm.h Merge.cpp MergeDoc.cpp OpenDlg.cpp
+   PathContext.cpp
+  Src/Common: coretools.cpp
 
 2005-12-16 Kimmo
  PATCH: [ 1381984 ] Folder compare progressdialog could be drawn off-screen
index 38be751..f453e84 100644 (file)
@@ -7,9 +7,6 @@
 // RCS ID line follows -- this is updated by CVS
 // $Id$
 #include "stdafx.h"
-#ifndef __AFXDISP_H__
-#include <afxdisp.h>
-#endif // __AFXDISP_H__
 #include <stdio.h>
 #include <io.h>
 #include <mbctype.h> // MBCS (multibyte codepage stuff)
index 09bee2a..3d16d13 100644 (file)
@@ -757,11 +757,7 @@ void CMainFrame::OnHelpGnulicense()
        CString spath = GetModulePath() + _T("\\Copying");
        CString url = _T("http://www.gnu.org/copyleft/gpl.html");
        
-       CFileStatus status;
-       if (CFile::GetStatus(spath, status))
-               ShellExecute(m_hWnd, _T("open"), _T("notepad.exe"), spath, NULL, SW_SHOWNORMAL);
-       else
-               ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWNORMAL);
+       OpenFileOrUrl(spath, url);
 }
 
 /**
@@ -1454,10 +1450,9 @@ BOOL CMainFrame::DoFileOpen(LPCTSTR pszLeft /*=NULL*/, LPCTSTR pszRight /*=NULL*
 BOOL CMainFrame::CreateBackup(LPCTSTR pszPath)
 {
        // first, make a backup copy of the original
-       CFileStatus status;
-
        // create backup copy of file if destination file exists
-       if (m_options.GetBool(OPT_CREATE_BACKUPS) && CFile::GetStatus(pszPath, status))
+       if (m_options.GetBool(OPT_CREATE_BACKUPS) 
+               && paths_DoesPathExist(pszPath) == IS_EXISTING_FILE)
        {
                // Add backup extension if pathlength allows it
                BOOL success = TRUE;
@@ -1740,16 +1735,22 @@ BOOL CMainFrame::IsComparing()
        return FALSE;
 }
 
+/**
+ * @brief Open file, if it exists, else open url
+ */
+void CMainFrame::OpenFileOrUrl(LPCTSTR szFile, LPCTSTR szUrl)
+{
+       if (paths_DoesPathExist(szFile) == IS_EXISTING_FILE)
+               ShellExecute(m_hWnd, _T("open"), _T("notepad.exe"), szFile, NULL, SW_SHOWNORMAL);
+       else
+               ShellExecute(NULL, _T("open"), szUrl, NULL, NULL, SW_SHOWNORMAL);
+}
+
 void CMainFrame::OnHelpContents() 
 {
        CString spath = GetModulePath(0) + DocsPath;
 
-       CFileStatus status;
-       if (CFile::GetStatus(spath, status))
-               ShellExecute(NULL, _T("open"), spath, NULL, NULL, SW_SHOWNORMAL);
-       else
-               ShellExecute(NULL, _T("open"), DocsURL, NULL, NULL, SW_SHOWNORMAL);
-
+       OpenFileOrUrl(spath, DocsURL);
 }
 
 void CMainFrame::OnUpdateHelpContents(CCmdUI* pCmdUI) 
index cad17ac..b6db085 100644 (file)
@@ -265,6 +265,7 @@ private:
        CDirDoc * GetDirDocToShow(BOOL * pNew);
        void ShowFontChangeMessage();
        void OptionsInit();
+       void OpenFileOrUrl(LPCTSTR szFile, LPCTSTR szUrl);
 };
 
 extern CMainFrame *mf;
index d21b640..b68d4d6 100644 (file)
@@ -606,9 +606,7 @@ BOOL SelectFile(CString& path, LPCTSTR root_path /*=NULL*/,
        // check if specified path is a file
        if (root_path!=NULL)
        {
-               CFileStatus status;
-               if (CFile::GetStatus(root_path,status)
-                       && (status.m_attribute!=CFile::Attribute::directory))
+               if (paths_DoesPathExist(root_path) == IS_EXISTING_FILE)
                {
                        SplitFilename(root_path, 0, &sfile, 0);
                }
@@ -851,8 +849,7 @@ void CAboutDlg::OnBnClickedOpenContributors()
        CString docPath = defPath + _T("\\contributors.txt");
        HINSTANCE ret = 0;
        
-       CFileStatus status;
-       if (CFile::GetStatus(docPath, status))
+       if (paths_DoesPathExist(docPath) == IS_EXISTING_FILE)
        {
                // Now, add quotation marks so ShellExecute() doesn't fail if path
                // includes spaces
index acb6415..e5674ce 100644 (file)
@@ -58,6 +58,7 @@
 #include "sbuffer.h"
 #include "dllver.h"
 #include "codepage.h"
+#include "paths.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -999,9 +1000,7 @@ BOOL CMergeDoc::DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, int nBuffer)
        // Check third arg possibly given from command-line
        if (!mf->m_strSaveAsPath.IsEmpty())
        {
-               CFileStatus status;
-               if (CFile::GetStatus(mf->m_strSaveAsPath, status)
-                       && (status.m_attribute & CFile::Attribute::directory))
+               if (paths_DoesPathExist(mf->m_strSaveAsPath) == IS_EXISTING_DIR)
                {
                        // third arg was a directory, so get append the filename
                        CString sname;
index ed88c0d..e38810e 100644 (file)
@@ -117,13 +117,12 @@ void COpenDlg::OnLeftButton()
        CString s;
        CString sfolder, sext;
        CString dirSelTag;
-       CFileStatus status;
        UpdateData(TRUE); 
 
+
        VERIFY(dirSelTag.LoadString(IDS_DIRSEL_TAG));
-       if (CFile::GetStatus(m_strLeft, status)
-               && (status.m_attribute & CFile::Attribute::directory))
-                       sfolder = m_strLeft;
+       if (paths_DoesPathExist(m_strLeft) == IS_EXISTING_DIR)
+               sfolder = m_strLeft;
        else
                sfolder = GetPathOnly(m_strLeft);
        if (SelectFile(s, sfolder))
@@ -146,13 +145,11 @@ void COpenDlg::OnRightButton()
        CString s;
        CString sfolder, sext;
        CString dirSelTag;
-       CFileStatus status;
        UpdateData(TRUE);
 
        VERIFY(dirSelTag.LoadString(IDS_DIRSEL_TAG));
-       if (CFile::GetStatus(m_strRight, status)
-               && (status.m_attribute & CFile::Attribute::directory))
-                       sfolder = m_strRight;
+       if (paths_DoesPathExist(m_strRight) == IS_EXISTING_DIR)
+               sfolder = m_strRight;
        else 
                sfolder = GetPathOnly(m_strRight);
        if (SelectFile(s, sfolder))
index e39294e..2d268ac 100644 (file)
@@ -216,17 +216,15 @@ BOOL TempFileContext::CreateFiles(const PathContext &paths)
  */
 BOOL TempFileContext::FilesExist()
 {
-       CFileStatus s1,s2;
        BOOL bLeftExists = FALSE;
        BOOL bRightExists = FALSE;
 
        if (!GetLeft().IsEmpty())
-               bLeftExists = CFile::GetStatus(GetLeft(), s1);
+               bLeftExists = (paths_DoesPathExist(GetLeft()) == IS_EXISTING_FILE);
        if (!GetRight().IsEmpty())
-               bRightExists = CFile::GetStatus(GetRight(), s2);
+               bLeftExists = (paths_DoesPathExist(GetRight()) == IS_EXISTING_FILE);
        
        return bLeftExists || bRightExists;
-
 }
 
 /**