forked from qt-creator/qt-creator
Utils: Move filterEntriesHelper() out of FilePath
Currently only used inside DockerDevice and it fails to build when building sdktool with old Qt which is still necessary. Change-Id: Ic48414f0cb8f0955e7561f7484e3ea1c726c816a Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -710,40 +710,6 @@ FilePaths FilePath::dirEntries(const QStringList &nameFilters,
|
||||
return Utils::transform(entryInfoList, &FilePath::fromFileInfo);
|
||||
}
|
||||
|
||||
FilePaths FilePath::filterEntriesHelper(const FilePath &base,
|
||||
const QStringList &entries,
|
||||
const QStringList &nameFilters,
|
||||
QDir::Filters filters,
|
||||
QDir::SortFlags sort)
|
||||
{
|
||||
const QList<QRegularExpression> nameRegexps = transform(nameFilters, [](const QString &filter) {
|
||||
QRegularExpression re;
|
||||
re.setPattern(QRegularExpression::wildcardToRegularExpression(filter));
|
||||
QTC_CHECK(re.isValid());
|
||||
return re;
|
||||
});
|
||||
|
||||
const auto nameMatches = [&nameRegexps](const QString &fileName) {
|
||||
for (const QRegularExpression &re : nameRegexps) {
|
||||
const QRegularExpressionMatch match = re.match(fileName);
|
||||
if (match.hasMatch())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// FIXME: Handle sort and filters. For now bark on unsupported options.
|
||||
QTC_CHECK(filters == QDir::NoFilter);
|
||||
QTC_CHECK(sort == QDir::NoSort);
|
||||
|
||||
FilePaths result;
|
||||
for (const QString &entry : entries) {
|
||||
if (!nameMatches(entry))
|
||||
continue;
|
||||
result.append(base.pathAppended(entry));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<FilePath> FilePath::dirEntries(QDir::Filters filters) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user