| 603 | } |
| 604 | |
| 605 | void FileRules::Impl::validateNewRule(size_t ruleIndex, const char * name) const |
| 606 | { |
| 607 | if (!name || !*name) |
| 608 | { |
| 609 | throw Exception("File rules: rule should have a non-empty name."); |
| 610 | } |
| 611 | auto existingRule = std::find_if(m_rules.begin(), m_rules.end(), |
| 612 | [name](const FileRuleRcPtr & rule) |
| 613 | { |
| 614 | return 0==Platform::Strcasecmp(name, rule->getName()); |
| 615 | }); |
| 616 | if (existingRule != m_rules.end()) |
| 617 | { |
| 618 | std::ostringstream oss; |
| 619 | oss << "File rules: A rule named '" << name << "' already exists."; |
| 620 | throw Exception(oss.str().c_str()); |
| 621 | } |
| 622 | validatePosition(ruleIndex, DEFAULT_ALLOWED); |
| 623 | if (0==Platform::Strcasecmp(name, FileRules::DefaultRuleName)) |
| 624 | { |
| 625 | std::ostringstream oss; |
| 626 | oss << "File rules: Default rule already exists at index " |
| 627 | << " '" << m_rules.size() - 1 << "'."; |
| 628 | throw Exception(oss.str().c_str()); |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | const char * FileRules::Impl::getRuleFromFilepath(const Config & config, const char * filePath, |
| 633 | size_t & ruleIndex) const |
no test coverage detected