diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index eda575945ae..a5264d17987 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -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 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::dirEntries(QDir::Filters filters) const { diff --git a/src/libs/utils/filepath.h b/src/libs/utils/filepath.h index d53357057db..6ece9ea162a 100644 --- a/src/libs/utils/filepath.h +++ b/src/libs/utils/filepath.h @@ -173,11 +173,6 @@ public: static void removeDuplicates(QList &files); static void sort(QList &files); - static QList filterEntriesHelper(const FilePath &base, - const QStringList &entries, - const QStringList &nameFilters, - QDir::Filters filters, - QDir::SortFlags sort); private: friend class ::tst_fileutils; static QString calcRelativePath(const QString &absolutePath, const QString &absoluteAnchorPath); diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 54f3c1ddf7b..ff7745761c8 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index eb0508d4b2c..bacbc36204c 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -1274,6 +1275,41 @@ FilePath DockerDevice::symLinkTarget(const FilePath &filePath) const return output.isEmpty() ? FilePath() : filePath.withNewPath(output); } +static FilePaths filterEntriesHelper(const FilePath &base, + const QStringList &entries, + const QStringList &nameFilters, + QDir::Filters filters, + QDir::SortFlags sort) +{ + const QList 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; +} + FilePaths DockerDevice::directoryEntries(const FilePath &filePath, const QStringList &nameFilters, QDir::Filters filters, @@ -1290,7 +1326,7 @@ FilePaths DockerDevice::directoryEntries(const FilePath &filePath, const QString output = d->outputForRunInShell({"ls", {"-1", "-b", "--", filePath.path()}}); QStringList entries = output.split('\n', Qt::SkipEmptyParts); - return FilePath::filterEntriesHelper(filePath, entries, nameFilters, filters, sort); + return filterEntriesHelper(filePath, entries, nameFilters, filters, sort); } QByteArray DockerDevice::fileContents(const FilePath &filePath, qint64 limit, qint64 offset) const