@@ -23,7 +23,7 @@ using Poco::Glob;
2323using Poco::icompare;
2424using Poco::RegularExpression;
2525
26- static void AddFilterPattern (vector<FileFilterElementPtr> *filterList, String & str);
26+ static void AddFilterPattern (vector<FileFilterElementPtr> *filterList, String & str, bool fileFilter );
2727
2828/* *
2929 * @brief Destructor, frees all filters.
@@ -119,7 +119,7 @@ void FileFilterMgr::DeleteAllFilters()
119119 * @param [in] filterList List where pattern is added.
120120 * @param [in] str Temporary variable (ie, it may be altered)
121121 */
122- static void AddFilterPattern (vector<FileFilterElementPtr> *filterList, String & str)
122+ static void AddFilterPattern (vector<FileFilterElementPtr> *filterList, String & str, bool fileFilter )
123123{
124124 const String& commentLeader = _T (" ##" ); // Starts comment
125125 str = strutils::trim_ws_begin (str);
@@ -145,7 +145,7 @@ static void AddFilterPattern(vector<FileFilterElementPtr> *filterList, String &
145145 re_opts |= RegularExpression::RE_UTF8;
146146 try
147147 {
148- filterList->push_back (FileFilterElementPtr (new FileFilterElement (regexString, re_opts)));
148+ filterList->push_back (FileFilterElementPtr (new FileFilterElement (regexString, re_opts, fileFilter )));
149149 }
150150 catch (...)
151151 {
@@ -218,25 +218,25 @@ FileFilter * FileFilterMgr::LoadFilterFile(const String& szFilepath, int & error
218218 {
219219 // file filter
220220 String str = sLine .substr (2 );
221- AddFilterPattern (&pfilter->filefilters , str);
221+ AddFilterPattern (&pfilter->filefilters , str, true );
222222 }
223223 else if (0 == sLine .compare (0 , 2 , _T (" d:" ), 2 ))
224224 {
225225 // directory filter
226226 String str = sLine .substr (2 );
227- AddFilterPattern (&pfilter->dirfilters , str);
227+ AddFilterPattern (&pfilter->dirfilters , str, false );
228228 }
229229 else if (0 == sLine .compare (0 , 3 , _T (" f!:" ), 3 ))
230230 {
231231 // file filter
232232 String str = sLine .substr (3 );
233- AddFilterPattern (&pfilter->filefiltersExclude , str);
233+ AddFilterPattern (&pfilter->filefiltersExclude , str, true );
234234 }
235235 else if (0 == sLine .compare (0 , 3 , _T (" d!:" ), 3 ))
236236 {
237237 // directory filter
238238 String str = sLine .substr (3 );
239- AddFilterPattern (&pfilter->dirfiltersExclude , str);
239+ AddFilterPattern (&pfilter->dirfiltersExclude , str, false );
240240 }
241241 } while (bLinesLeft);
242242
@@ -289,15 +289,17 @@ bool TestAgainstRegList(const vector<FileFilterElementPtr> *filterList, const St
289289 if (filterList->size () == 0 )
290290 return false ;
291291
292- std::string compString;
292+ std::string compString, compStringFileName ;
293293 ucr::toUTF8 (szTest, compString);
294294 vector<FileFilterElementPtr>::const_iterator iter = filterList->begin ();
295295 while (iter != filterList->end ())
296296 {
297297 RegularExpression::Match match;
298298 try
299299 {
300- if ((*iter)->regexp .match (compString, 0 , match) > 0 )
300+ if ((*iter)->_fileNameOnly && compStringFileName.empty ())
301+ ucr::toUTF8 (paths::FindFileName (szTest), compStringFileName);
302+ if ((*iter)->regexp .match ((*iter)->_fileNameOnly ? compStringFileName : compString, 0 , match) > 0 )
301303 return true ;
302304 }
303305 catch (...)
0 commit comments