diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 8b79923c516..91d692a1a70 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -398,13 +398,13 @@ bool FileUtils::isRelativePath(const QString &path) return true; } -QString FileUtils::resolvePath(const QString &baseDir, const QString &fileName) +FilePath FilePath::resolvePath(const QString &fileName) const { if (fileName.isEmpty()) - return QString(); - if (isAbsolutePath(fileName)) - return QDir::cleanPath(fileName); - return QDir::cleanPath(baseDir + QLatin1Char('/') + fileName); + return {}; // FIXME: Isn't this odd? + if (FileUtils::isAbsolutePath(fileName)) + return FilePath::fromString(QDir::cleanPath(fileName)); + return FilePath::fromString(QDir::cleanPath(toString() + QLatin1Char('/') + fileName)); } FilePath FileUtils::commonPath(const FilePath &oldCommonPath, const FilePath &filePath) diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index 4d1243cfdf7..75315c7977d 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -107,6 +107,7 @@ public: FilePath relativeChildPath(const FilePath &parent) const; FilePath pathAppended(const QString &str) const; FilePath stringAppended(const QString &str) const; + FilePath resolvePath(const QString &fileName) const; FilePath canonicalPath() const; @@ -172,7 +173,6 @@ public: static bool isRelativePath(const QString &fileName); static bool isAbsolutePath(const QString &fileName) { return !isRelativePath(fileName); } - static QString resolvePath(const QString &baseDir, const QString &fileName); static FilePath commonPath(const FilePath &oldCommonPath, const FilePath &fileName); static QByteArray fileId(const FilePath &fileName); }; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 6cf048420e9..b9e462c9a57 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4700,8 +4700,8 @@ static QString findExecutableFromName(const QString &fileNameFromCore, const QSt absPath = fileNameFromCore; } else { QFileInfo coreInfo(coreFile); - QDir coreDir = coreInfo.dir(); - absPath = FileUtils::resolvePath(coreDir.absolutePath(), fileNameFromCore); + FilePath coreDir = FilePath::fromString(coreInfo.dir().absolutePath()); + absPath = coreDir.resolvePath(fileNameFromCore).toString(); } if (QFileInfo(absPath).isFile() || absPath.isEmpty()) return absPath; diff --git a/src/plugins/projectexplorer/customparser.cpp b/src/plugins/projectexplorer/customparser.cpp index c408dfc2c65..9c97bc17724 100644 --- a/src/plugins/projectexplorer/customparser.cpp +++ b/src/plugins/projectexplorer/customparser.cpp @@ -155,7 +155,7 @@ FilePath CustomParser::absoluteFilePath(const QString &filePath) const if (m_workingDirectory.isEmpty()) return FilePath::fromUserInput(filePath); - return FilePath::fromString(FileUtils::resolvePath(m_workingDirectory, filePath)); + return FilePath::fromString(m_workingDirectory).resolvePath(filePath); } bool CustomParser::hasMatch(const QString &line, CustomParserExpression::CustomParserChannel channel, diff --git a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp index 4e429827473..1ce47c7043b 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp @@ -66,9 +66,9 @@ static FilePath defaultBuildDirectory(const FilePath &projectFilePath, const Kit { const QString projectName = projectFilePath.toFileInfo().completeBaseName(); ProjectMacroExpander expander(projectFilePath, projectName, k, bcName, buildType); - QString projectDir = Project::projectDirectory(projectFilePath).toString(); + FilePath projectDir = Project::projectDirectory(projectFilePath); QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate()); - return FilePath::fromString(FileUtils::resolvePath(projectDir, buildPath)); + return projectDir.resolvePath(buildPath); } // --------------------------------------------------------------------------- diff --git a/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp b/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp index 46b1719d84f..9e30a86cada 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectimporter.cpp @@ -86,14 +86,14 @@ QbsProjectImporter::QbsProjectImporter(const FilePath &path) : QtProjectImporter { } -static QString buildDir(const FilePath &projectFilePath, const Kit *k) +static FilePath buildDir(const FilePath &projectFilePath, const Kit *k) { const QString projectName = projectFilePath.toFileInfo().completeBaseName(); ProjectMacroExpander expander(projectFilePath, projectName, k, QString(), BuildConfiguration::Unknown); - const QString projectDir = Project::projectDirectory(projectFilePath).toString(); + const FilePath projectDir = Project::projectDirectory(projectFilePath); const QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate()); - return FileUtils::resolvePath(projectDir, buildPath); + return projectDir.resolvePath(buildPath); } static bool hasBuildGraph(const QString &dir) @@ -123,7 +123,7 @@ QStringList QbsProjectImporter::importCandidates() seenCandidates.insert(projectDir); const auto &kits = KitManager::kits(); for (Kit * const k : kits) { - QFileInfo fi(buildDir(projectFilePath(), k)); + QFileInfo fi = buildDir(projectFilePath(), k).toFileInfo(); const QString candidate = fi.absolutePath(); if (!seenCandidates.contains(candidate)) { seenCandidates.insert(candidate); diff --git a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp index cca243d66a6..0e20d1920b2 100644 --- a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp @@ -86,9 +86,9 @@ FilePath QmakeBuildConfiguration::shadowBuildDirectory(const FilePath &proFilePa const QString projectName = proFilePath.toFileInfo().completeBaseName(); ProjectMacroExpander expander(proFilePath, projectName, k, suffix, buildType); - QString projectDir = Project::projectDirectory(proFilePath).toString(); + FilePath projectDir = Project::projectDirectory(proFilePath); QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate()); - return FilePath::fromString(FileUtils::resolvePath(projectDir, buildPath)); + return projectDir.resolvePath(buildPath); } const char BUILD_CONFIGURATION_KEY[] = "Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration"; diff --git a/src/plugins/winrt/winrtpackagedeploymentstep.cpp b/src/plugins/winrt/winrtpackagedeploymentstep.cpp index c410de4bf45..7cd90bac349 100644 --- a/src/plugins/winrt/winrtpackagedeploymentstep.cpp +++ b/src/plugins/winrt/winrtpackagedeploymentstep.cpp @@ -91,8 +91,7 @@ bool WinRtPackageDeploymentStep::init() if (!qt) return false; - const QString windeployqtPath = FileUtils::resolvePath(qt->hostBinPath().toString(), - "windeployqt.exe"); + const FilePath windeployqtPath = qt->hostBinPath().resolvePath("windeployqt.exe"); CommandLine windeployqt{windeployqtPath}; windeployqt.addArg(QDir::toNativeSeparators(m_targetFilePath)); @@ -104,7 +103,7 @@ bool WinRtPackageDeploymentStep::init() } ProcessParameters *params = processParameters(); - if (!QFile::exists(windeployqtPath)) { + if (!windeployqtPath.exists()) { raiseError(tr("Cannot find windeployqt.exe in \"%1\".") .arg(QDir::toNativeSeparators(qt->hostBinPath().toString()))); return false;