OSDN Git Service

PATCH: [ 804493 ] Read filter files from users profile directory
authorKimmo Varis <kimmov@gmail.com>
Mon, 15 Sep 2003 18:29:36 +0000 (18:29 +0000)
committerKimmo Varis <kimmov@gmail.com>
Mon, 15 Sep 2003 18:29:36 +0000 (18:29 +0000)
Src/Common/coretools.cpp
Src/Common/coretools.h
Src/FileFilterMgr.cpp
Src/Merge.cpp
Src/readme.txt

index 5d6cd1b..a038542 100644 (file)
@@ -1,10 +1,27 @@
-/*******************************************************************************
-$RCSfile$
-$Author$
-$Date$
-
-*******************************************************************************/
-
+/////////////////////////////////////////////////////////////////////////////
+//    License (GPLv2+):
+//    This program is free software; you can redistribute it and/or modify
+//    it under the terms of the GNU General Public License as published by
+//    the Free Software Foundation; either version 2 of the License, or (at
+//    your option) any later version.
+//    
+//    This program is distributed in the hope that it will be useful, but
+//    WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//    GNU General Public License for more details.
+//
+//    You should have received a copy of the GNU General Public License
+//    along with this program; if not, write to the Free Software
+//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+/////////////////////////////////////////////////////////////////////////////
+/** 
+ * @file  Coretools.cpp
+ *
+ * @brief Common routines
+ *
+ */
+// RCS ID line follows -- this is updated by CVS
+// $Id$
 #include "stdafx.h"
 #include <stdio.h>
 #include <io.h>
@@ -304,7 +321,7 @@ void SplitFilename(LPCTSTR pathLeft, CString* pPath, CString* pFile, CString* pE
                        {
                                if (pExt)
                                {
-                               (*pExt) = pszChar + 1;
+                                       (*pExt) = pszChar + 1;
                                }
                                ext = true; // extension is only after last period
                                extptr = pszChar;
@@ -1182,8 +1199,21 @@ CString GetPathOnly(LPCTSTR fullpath)
        return spath;
 }
 
-
-/*******************************************************************************
-       END OF FILE
-*******************************************************************************/
-
+/** 
+ * @brief Returns Application Data path in user profile directory
+ * if one exists
+ */
+BOOL GetAppDataPath(CString &sAppDataPath)
+{
+       TCHAR path[_MAX_PATH] = {0};
+       if (GetEnvironmentVariable(_T("APPDATA"), path, _MAX_PATH))
+       {       
+               sAppDataPath = path;
+               return TRUE;
+       }
+       else
+       {
+               sAppDataPath = _T("");
+               return FALSE;
+       }
+}
index 6b534de..54d1bbb 100644 (file)
@@ -1,3 +1,27 @@
+/////////////////////////////////////////////////////////////////////////////
+//    License (GPLv2+):
+//    This program is free software; you can redistribute it and/or modify
+//    it under the terms of the GNU General Public License as published by
+//    the Free Software Foundation; either version 2 of the License, or
+//    (at your option) any later version.
+//
+//    This program is distributed in the hope that it will be useful, but
+//    WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    General Public License for more details.
+//
+//    You should have received a copy of the GNU General Public License
+//    along with this program; if not, write to the Free Software
+//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+/////////////////////////////////////////////////////////////////////////////
+/** 
+ * @file  Coretools.h
+ *
+ * @brief Declaration file for Coretools.cpp
+ */
+// RCS ID line follows -- this is updated by CVS
+// $Id$
+
 #ifndef CORETOOLS_H
 #define CORETOOLS_H
 
@@ -131,5 +155,6 @@ void WriteWcsFromMbs(CArchive* ar, LPCTSTR szSrc, DWORD dwCount);
 HANDLE RunIt(LPCTSTR szExeFile, LPCTSTR szArgs, BOOL bMinimized = TRUE, BOOL bNewConsole = FALSE);
 BOOL HasExited(HANDLE hProcess, DWORD *pCode = NULL);
 BOOL IsLocalPath(LPCTSTR path);
+BOOL GetAppDataPath(CString &sAppDataPath);
 
 #endif
index 58b2bbf..3ee4417 100644 (file)
@@ -59,7 +59,7 @@ FileFilterMgr::~FileFilterMgr()
 // Load 
 void FileFilterMgr::LoadFromDirectory(LPCTSTR szPattern, LPCTSTR szExt)
 {
-       DeleteAllFilters();
+       // DeleteAllFilters();
        CFileFind finder;
        BOOL bWorking = finder.FindFile(szPattern);
        int extlen = szExt ? _tcslen(szExt) : 0;
index 5ed042c..2477c2b 100644 (file)
 //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 //
 /////////////////////////////////////////////////////////////////////////////
-// Merge.cpp : Defines the class behaviors for the application.
-//
+/** 
+ * @file  Merge.cpp
+ *
+ * @brief Defines the class behaviors for the application.
+ *
+ */
+// RCS ID line follows -- this is updated by CVS
+// $Id$
 
 #include "stdafx.h"
 #include "Merge.h"
@@ -250,7 +256,7 @@ BOOL CMergeApp::InitInstance()
        return TRUE;
 }
 
-// Process commandline arguments
+/// Process commandline arguments
 void CMergeApp::ParseArgs(CStringArray & files, UINT & nFiles, BOOL & recurse, DWORD & dwLeftFlags, DWORD & dwRightFlags)
 {
        for (int i = 1; i < __argc; i++)
@@ -269,7 +275,7 @@ void CMergeApp::ParseArgs(CStringArray & files, UINT & nFiles, BOOL & recurse, D
                        if (!_tcsicmp(pszParam, _T("e")))
                                m_bEscCloses = TRUE;
 
-                       // -ur to not add left path to MEU
+                       // -ul to not add left path to MRU
                        if (!_tcsicmp(pszParam, _T("ul")))
                                dwLeftFlags |= FFILEOPEN_NOMRU;
 
@@ -655,8 +661,10 @@ int CMergeApp::DoMessageBox(LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt)
        return CWinApp::DoMessageBox(lpszPrompt, nType, nIDPrompt);
 }
 
-// Set flag so that application will broadcast notification at next
-// idle time (via WM_TIMER id=IDLE_TIMER)
+/** 
+ * @brief Set flag so that application will broadcast notification at next
+ * idle time (via WM_TIMER id=IDLE_TIMER)
+ */
 void CMergeApp::SetNeedIdleTimer()
 {
        m_bNeedIdleTimer = TRUE; 
@@ -676,7 +684,7 @@ BOOL CMergeApp::OnIdle(LONG lCount)
        return FALSE;
 }
 
-// Load any known file filters
+/** @brief Load any known file filters */
 void CMergeApp::InitializeFileFilters()
 {
        if (!m_fileFilterMgr)
@@ -684,9 +692,17 @@ void CMergeApp::InitializeFileFilters()
 
        CString sPattern = GetModulePath() + _T("\\Filters\\*.flt");
        m_fileFilterMgr->LoadFromDirectory(sPattern, _T(".flt"));
+
+       // Get Application data path in user profile directory
+       if (GetAppDataPath(sPattern))
+       {
+               // Load filters from subdir
+               sPattern += _T("\\WinMerge\\Filters\\*.flt");
+               m_fileFilterMgr->LoadFromDirectory(sPattern, _T(".flt"));
+       }
 }
 
-// fill list with names of known filters
+/** @brief fill list with names of known filters */
 void CMergeApp::GetFileFilterNameList(CStringList & filefilters, CString & selected) const
 {
        if (!m_fileFilterMgr) return;
@@ -697,7 +713,7 @@ void CMergeApp::GetFileFilterNameList(CStringList & filefilters, CString & selec
        selected = m_sFileFilterName;
 }
 
-// Store current filter (if filter manager validates the name)
+/** @brief Store current filter (if filter manager validates the name) */
 void CMergeApp::SetFileFilterName(LPCTSTR szFileFilterName)
 {
        m_sFileFilterName = _T("<None>");
index 1814c37..7bfb67b 100644 (file)
@@ -1,11 +1,15 @@
 2003-09-15 Kimmo
- BUG [ 806552 ] DirView icons missing?
+ BUG: [ 806552 ] DirView icons missing?
   Adding icons for skipped files and folders
   WinMerge: DirView.cpp Merge.rc resource.h
   WinMerge/res: new files fileskip.bmp folderskip.bmp
   Languages: resource.h *.rc new files /res fileskip.bmp folderskip.bmp
  Don't color skipped items filenames in directory compare
   WinMerge: DirView.cpp
+ PATCH: [ 804493 ] Read filter files from users profile directory
+  NOTE: Filters are read from %profiledir%/Application Data/WinMerge/Filters
+  common: coretools.h coretools.cpp
+  WinMerge: FileFilterMgr.cpp Merge.cpp
 
 2003-09-14 Perry
  PATCH: [ 805875 ] Switch to diffcode flags