* @brief Check if any of filefilter rules match to filename. * * @param [in] szFileName Filename to test. * @return true unless we're suppressing this file by filter */
| 174 | * @return true unless we're suppressing this file by filter |
| 175 | */ |
| 176 | bool FileFilterHelper::includeFile(const String& szFileName) const |
| 177 | { |
| 178 | // preprend a backslash if there is none |
| 179 | String strFileName = strutils::makelower(szFileName); |
| 180 | if (strFileName.empty() || strFileName[0] != '\\') |
| 181 | strFileName = _T("\\") + strFileName; |
| 182 | // append a point if there is no extension |
| 183 | std::string strFileNameUtf8Period = ucr::toUTF8(addPeriodIfNoExtension(strFileName)); |
| 184 | for (const auto& filterGroup : m_filterGroups) |
| 185 | { |
| 186 | bool result = filterGroup.m_pMaskFileFilter && filterGroup.m_pMaskFileFilter->Match(strFileNameUtf8Period); |
| 187 | if (!result) |
| 188 | result = filterGroup.m_pRegexOrExpressionFilter && TestAgainstRegList(&filterGroup.m_pRegexOrExpressionFilter->filefilters, szFileName); |
| 189 | if (!result) |
| 190 | return false; |
| 191 | if (filterGroup.m_pMaskFileFilterExclude && filterGroup.m_pMaskFileFilterExclude->Match(strFileNameUtf8Period)) |
| 192 | return false; |
| 193 | if (filterGroup.m_pRegexOrExpressionFilter && TestAgainstRegList(&filterGroup.m_pRegexOrExpressionFilter->filefiltersExclude, szFileName)) |
| 194 | return false; |
| 195 | if (filterGroup.m_pRegexOrExpressionFilterExclude && !filterGroup.m_pRegexOrExpressionFilterExclude->TestFileNameAgainstFilter(szFileName)) |
| 196 | return false; |
| 197 | } |
| 198 | return true; |
| 199 | } |
| 200 | |
| 201 | bool FileFilterHelper::includeFile(const DIFFITEM& di) const |
| 202 | { |