| 86 | } |
| 87 | |
| 88 | bool KDevFormatFile::apply() |
| 89 | { |
| 90 | for (const KDevFormatLine& formatLine : std::as_const(m_formatLines)) { |
| 91 | if (formatLine.wildcards.isEmpty()) { |
| 92 | qStdOut() << "matched \"" << m_origFilePath << "\" without wildcard"; |
| 93 | return executeCommand(formatLine.command); |
| 94 | } |
| 95 | |
| 96 | const QChar dirSeparator = QDir::separator(); |
| 97 | for (const QString& wildcard : formatLine.wildcards) { |
| 98 | const QString pattern = QDir::current().canonicalPath() + dirSeparator + wildcard.trimmed(); |
| 99 | if (WildcardHelpers::matchSinglePattern(pattern, m_origFilePath)) { |
| 100 | qStdOut() << "matched \"" << m_origFilePath << "\" with wildcard \"" << wildcard << '\"'; |
| 101 | return executeCommand(formatLine.command); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | qStdOut() << formatFileName << ": error: no commands applicable to \"" << m_origFilePath << "\"\n"; |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | bool KDevFormatFile::executeCommand(QString command) |
| 111 | { |