From b3323ac999f2203d6c54d8f8c9006eccc9c54286 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Mon, 15 Sep 2003 18:29:36 +0000 Subject: [PATCH] PATCH: [ 804493 ] Read filter files from users profile directory --- Src/Common/coretools.cpp | 56 +++++++++++++++++++++++++++++++++++++----------- Src/Common/coretools.h | 25 +++++++++++++++++++++ Src/FileFilterMgr.cpp | 2 +- Src/Merge.cpp | 34 +++++++++++++++++++++-------- Src/readme.txt | 6 +++++- 5 files changed, 99 insertions(+), 24 deletions(-) diff --git a/Src/Common/coretools.cpp b/Src/Common/coretools.cpp index 5d6cd1b2b..a03854242 100644 --- a/Src/Common/coretools.cpp +++ b/Src/Common/coretools.cpp @@ -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 #include @@ -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; + } +} diff --git a/Src/Common/coretools.h b/Src/Common/coretools.h index 6b534deb8..54d1bbb73 100644 --- a/Src/Common/coretools.h +++ b/Src/Common/coretools.h @@ -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 diff --git a/Src/FileFilterMgr.cpp b/Src/FileFilterMgr.cpp index 58b2bbf10..3ee4417d8 100644 --- a/Src/FileFilterMgr.cpp +++ b/Src/FileFilterMgr.cpp @@ -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; diff --git a/Src/Merge.cpp b/Src/Merge.cpp index 5ed042c92..2477c2b34 100644 --- a/Src/Merge.cpp +++ b/Src/Merge.cpp @@ -18,8 +18,14 @@ // 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(""); diff --git a/Src/readme.txt b/Src/readme.txt index 1814c3723..7bfb67b97 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -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 -- 2.11.0