From 305ccfe259d44a5828b6a770ea90d7c9e189120a Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 29 Mar 2023 13:45:42 +0200 Subject: [PATCH] Utils: Replace FilePath::onDevice() by new FilePath::withMappedPath() Basically a.onDevice(b) == b.withNewMappedPath(a), matching the order of b.withNewPath(a). Whether the (curretly docker-specific) path mapping is useful /there/, and whether some of the calls are needed at all is dubious. I added some FIXME and changed a few cases directly. Change-Id: I7514736ce922f632f1f737bc496f6783389a42b6 Reviewed-by: Marcus Tillmanns Reviewed-by: Qt CI Bot Reviewed-by: --- src/libs/utils/devicefileaccess.cpp | 20 +++++----- src/libs/utils/filepath.cpp | 39 ++++++++++--------- src/libs/utils/filepath.h | 2 +- src/libs/utils/terminalhooks.cpp | 2 +- src/plugins/clangcodemodel/clangdclient.cpp | 2 +- .../cmakebuildconfiguration.cpp | 2 +- .../cmakeprojectmanager/cmakebuildstep.cpp | 2 +- .../cmakeprojectmanager/cmakebuildsystem.cpp | 2 +- .../cmakeprojectmanager/cmakeinstallstep.cpp | 2 +- .../cmakekitinformation.cpp | 15 ++++--- .../cmakeprojectmanager/cmakeprocess.cpp | 4 +- .../fileapidataextractor.cpp | 2 +- src/plugins/debugger/debuggerruncontrol.cpp | 4 +- src/plugins/debugger/stackframe.cpp | 2 +- src/plugins/docker/dockerdevice.cpp | 4 +- src/plugins/languageclient/client.cpp | 2 +- .../projectexplorer/abstractprocessstep.cpp | 2 +- src/plugins/projectexplorer/gcctoolchain.cpp | 2 +- .../projectexplorer/runconfiguration.cpp | 2 +- .../runconfigurationaspects.cpp | 2 +- .../python/pysidebuildconfiguration.cpp | 2 +- src/plugins/python/pythonrunconfiguration.cpp | 6 +-- src/plugins/qtsupport/baseqtversion.cpp | 4 +- src/plugins/remotelinux/linuxdevice.cpp | 2 +- src/plugins/remotelinux/makeinstallstep.cpp | 4 +- src/plugins/valgrind/callgrindengine.cpp | 2 +- tests/auto/utils/filepath/tst_filepath.cpp | 10 ++--- 27 files changed, 71 insertions(+), 73 deletions(-) diff --git a/src/libs/utils/devicefileaccess.cpp b/src/libs/utils/devicefileaccess.cpp index 1e3c771ee7e..016310744b1 100644 --- a/src/libs/utils/devicefileaccess.cpp +++ b/src/libs/utils/devicefileaccess.cpp @@ -204,11 +204,8 @@ expected_str DeviceFileAccess::copyRecursively(const FilePath &src, #ifdef UTILS_STATIC_LIBRARY return copyRecursively_fallback(src, target); #else - const FilePath tar = FilePath::fromString("tar").onDevice(target); - const FilePath targetTar = tar.searchInPath(); - - const FilePath sTar = FilePath::fromString("tar").onDevice(src); - const FilePath sourceTar = sTar.searchInPath(); + const FilePath targetTar = target.withNewPath("tar").searchInPath(); + const FilePath sourceTar = src.withNewPath("tar").searchInPath(); const bool isSrcOrTargetQrc = src.toFSPathString().startsWith(":/") || target.toFSPathString().startsWith(":/"); @@ -683,12 +680,13 @@ expected_str DesktopDeviceFileAccess::createTempFile(const FilePath &f { QTemporaryFile file(filePath.path()); file.setAutoRemove(false); - if (!file.open()) - return make_unexpected(Tr::tr("Could not create temporary file in \"%1\" (%2)").arg(filePath.toUserOutput()).arg(file.errorString())); - return FilePath::fromString(file.fileName()).onDevice(filePath); + if (!file.open()) { + return make_unexpected(Tr::tr("Could not create temporary file in \"%1\" (%2)") + .arg(filePath.toUserOutput()).arg(file.errorString())); + } + return filePath.withNewPath(file.fileName()); } - QDateTime DesktopDeviceFileAccess::lastModified(const FilePath &filePath) const { return QFileInfo(filePath.path()).lastModified(); @@ -984,7 +982,7 @@ expected_str UnixDeviceFileAccess::createTempFile(const FilePath &file .arg(filePath.toUserOutput(), QString::fromUtf8(result.stdErr))); } - return FilePath::fromString(QString::fromUtf8(result.stdOut.trimmed())).onDevice(filePath); + return filePath.withNewPath(QString::fromUtf8(result.stdOut.trimmed())); } // Manually create a temporary/unique file. @@ -1008,7 +1006,7 @@ expected_str UnixDeviceFileAccess::createTempFile(const FilePath &file for (QChar *it = firstX.base(); it != std::end(tmplate); ++it) { *it = chars[dist(*QRandomGenerator::global())]; } - newPath = FilePath::fromString(tmplate).onDevice(filePath); + newPath = filePath.withNewPath(tmplate); if (--maxTries == 0) { return make_unexpected(Tr::tr("Failed creating temporary file \"%1\" (too many tries)") .arg(filePath.toUserOutput())); diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index e397ffe9b74..1781831712c 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -510,14 +510,14 @@ expected_str FilePath::tmpDir() const if (needsDevice()) { const Environment env = deviceEnvironment(); if (env.hasKey("TMPDIR")) - return FilePath::fromUserInput(env.value("TMPDIR")).onDevice(*this); + return withNewPath(env.value("TMPDIR")).cleanPath(); if (env.hasKey("TEMP")) - return FilePath::fromUserInput(env.value("TEMP")).onDevice(*this); + return withNewPath(env.value("TEMP")).cleanPath(); if (env.hasKey("TMP")) - return FilePath::fromUserInput(env.value("TMP")).onDevice(*this); + return withNewPath(env.value("TMP")).cleanPath(); if (osType() != OsTypeWindows) - return FilePath("/tmp").onDevice(*this); + return withNewPath("/tmp"); return make_unexpected(QString("Could not find temporary directory on device %1") .arg(displayName())); } @@ -1416,30 +1416,31 @@ QString FilePath::calcRelativePath(const QString &absolutePath, const QString &a } /*! - Returns a path corresponding to the current object on the - same device as \a deviceTemplate. The FilePath needs to be local. + Returns a path corresponding to \a newPath object on the + same device as the current object. + + This may involve device-specific translations like converting + windows style paths to unix style paths with suitable file + system case or handling of drive letters: C:/dev/src -> /c/dev/src Example usage: \code localDir = FilePath("/tmp/workingdir"); executable = FilePath::fromUrl("docker://123/bin/ls") - realDir = localDir.onDevice(executable) + realDir = executable.withNewMappedPath(localDir) assert(realDir == FilePath::fromUrl("docker://123/tmp/workingdir")) \endcode - - \param deviceTemplate A path from which the host and scheme is taken. */ -FilePath FilePath::onDevice(const FilePath &deviceTemplate) const +FilePath FilePath::withNewMappedPath(const FilePath &newPath) const { - isSameDevice(deviceTemplate); - const bool sameDevice = scheme() == deviceTemplate.scheme() && host() == deviceTemplate.host(); + const bool sameDevice = newPath.scheme() == scheme() && newPath.host() == host(); if (sameDevice) - return *this; + return newPath; // TODO: converting paths between different non local devices is still unsupported - QTC_CHECK(!needsDevice() || !deviceTemplate.needsDevice()); - return fromParts(deviceTemplate.scheme(), - deviceTemplate.host(), - deviceTemplate.fileAccess()->mapToDevicePath(path())); + QTC_CHECK(!newPath.needsDevice() || !needsDevice()); + FilePath res; + res.setParts(scheme(), host(), fileAccess()->mapToDevicePath(newPath.path())); + return res; } /*! @@ -1486,8 +1487,8 @@ FilePath FilePath::searchInPath(const FilePaths &additionalDirs, return *this; FilePaths directories = deviceEnvironment().path(); if (needsDevice()) { - directories = Utils::transform(directories, [this](const FilePath &path) { - return path.onDevice(*this); + directories = Utils::transform(directories, [this](const FilePath &filePath) { + return withNewPath(filePath.path()); }); } if (!additionalDirs.isEmpty()) { diff --git a/src/libs/utils/filepath.h b/src/libs/utils/filepath.h index 220c6de5daa..213eeb1e7b2 100644 --- a/src/libs/utils/filepath.h +++ b/src/libs/utils/filepath.h @@ -163,8 +163,8 @@ public: [[nodiscard]] FilePath searchInDirectories(const FilePaths &dirs, const FilePathPredicate &filter = {}) const; [[nodiscard]] Environment deviceEnvironment() const; - [[nodiscard]] FilePath onDevice(const FilePath &deviceTemplate) const; [[nodiscard]] FilePath withNewPath(const QString &newPath) const; + [[nodiscard]] FilePath withNewMappedPath(const FilePath &newPath) const; using IterateDirCallback = std::variant< diff --git a/src/libs/utils/terminalhooks.cpp b/src/libs/utils/terminalhooks.cpp index 6922f5c4304..d8e53010c30 100644 --- a/src/libs/utils/terminalhooks.cpp +++ b/src/libs/utils/terminalhooks.cpp @@ -27,7 +27,7 @@ FilePath defaultShellForDevice(const FilePath &deviceRoot) if (shell.isEmpty()) return shell; - return shell.onDevice(deviceRoot); + return deviceRoot.withNewMappedPath(shell); } class ExternalTerminalProcessImpl final : public TerminalInterface diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index 91a850f1b18..e71764ea2aa 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -213,7 +213,7 @@ static BaseClientInterface *clientInterface(Project *project, const Utils::FileP if (settings.clangdVersion() >= QVersionNumber(16)) cmd.addArg("--rename-file-limit=0"); if (!jsonDbDir.isEmpty()) - cmd.addArg("--compile-commands-dir=" + jsonDbDir.onDevice(clangdExePath).path()); + cmd.addArg("--compile-commands-dir=" + clangdExePath.withNewMappedPath(jsonDbDir).path()); if (clangdLogServer().isDebugEnabled()) cmd.addArgs({"--log=verbose", "--pretty"}); cmd.addArg("--use-dirty-headers"); diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 7cf47dc62d0..17871a590a3 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -701,7 +701,7 @@ void CMakeBuildSettingsWidget::updateConfigureDetailsWidgetsSummary( const FilePath buildDirectory = bc ? bc->buildDirectory() : "."; cmd.addArgs({"-S", m_buildSystem->projectDirectory().path()}); - cmd.addArgs({"-B", buildDirectory.onDevice(cmd.executable()).path()}); + cmd.addArgs({"-B", cmd.executable().withNewMappedPath(buildDirectory).path()}); // FIXME: Just buildDirectory.path() cmd.addArgs(configurationArguments); params.setCommandLine(cmd); diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index ccb21ccfb3e..e0ce29fc75c 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -383,7 +383,7 @@ CommandLine CMakeBuildStep::cmakeCommand() const if (buildConfiguration()) buildDirectory = buildConfiguration()->buildDirectory(); - cmd.addArgs({"--build", buildDirectory.onDevice(cmd.executable()).path()}); + cmd.addArgs({"--build", cmd.executable().withNewMappedPath(buildDirectory).path()}); cmd.addArg("--target"); cmd.addArgs(Utils::transform(m_buildTargets, [this](const QString &s) { diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index 02d1ca22532..5122f9a43ef 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -1303,7 +1303,7 @@ MakeInstallCommand CMakeBuildSystem::makeInstallCommand(const FilePath &installR buildDirectory = bc->buildDirectory(); cmd.command.addArg("--build"); - cmd.command.addArg(buildDirectory.onDevice(cmd.command.executable()).path()); + cmd.command.addArg(cmd.command.executable().withNewMappedPath(buildDirectory).path()); cmd.command.addArg("--target"); cmd.command.addArg(installTarget); diff --git a/src/plugins/cmakeprojectmanager/cmakeinstallstep.cpp b/src/plugins/cmakeprojectmanager/cmakeinstallstep.cpp index 6e6a49523f7..2c56388804a 100644 --- a/src/plugins/cmakeprojectmanager/cmakeinstallstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeinstallstep.cpp @@ -74,7 +74,7 @@ CommandLine CMakeInstallStep::cmakeCommand() const if (buildConfiguration()) buildDirectory = buildConfiguration()->buildDirectory(); - cmd.addArgs({"--install", buildDirectory.onDevice(cmd.executable()).path()}); + cmd.addArgs({"--install", cmd.executable().withNewMappedPath(buildDirectory).path()}); auto bs = qobject_cast(buildSystem()); if (bs && bs->isMultiConfigReader()) { diff --git a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp index 347c8e794c5..971b4c87445 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp +++ b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp @@ -1209,16 +1209,15 @@ Tasks CMakeConfigurationKitAspect::validate(const Kit *k) const FilePath tcCxxPath; for (const CMakeConfigItem &i : config) { // Do not use expand(QByteArray) as we cannot be sure the input is latin1 - const FilePath expandedValue - = FilePath::fromString(k->macroExpander()->expand(QString::fromUtf8(i.value))); + const QString expandedValue = k->macroExpander()->expand(QString::fromUtf8(i.value)); if (i.key == CMAKE_QMAKE_KEY) - qmakePath = expandedValue.onDevice(cmake->cmakeExecutable()); + qmakePath = cmake->cmakeExecutable().withNewPath(expandedValue); else if (i.key == CMAKE_C_TOOLCHAIN_KEY) - tcCPath = expandedValue.onDevice(cmake->cmakeExecutable()); + tcCPath = cmake->cmakeExecutable().withNewPath(expandedValue); else if (i.key == CMAKE_CXX_TOOLCHAIN_KEY) - tcCxxPath = expandedValue.onDevice(cmake->cmakeExecutable()); + tcCxxPath = cmake->cmakeExecutable().withNewPath(expandedValue); else if (i.key == CMAKE_PREFIX_PATH_KEY) - qtInstallDirs = CMakeConfigItem::cmakeSplitValue(expandedValue.path()); + qtInstallDirs = CMakeConfigItem::cmakeSplitValue(expandedValue); } Tasks result; @@ -1259,7 +1258,7 @@ Tasks CMakeConfigurationKitAspect::validate(const Kit *k) const if (!tcC || !tcC->isValid()) { addWarning(Tr::tr("CMake configuration has a path to a C compiler set, " "even though the kit has no valid tool chain.")); - } else if (tcCPath != tcC->compilerCommand() && tcCPath != tcC->compilerCommand().onDevice(tcCPath)) { + } else if (tcCPath != tcC->compilerCommand() && tcCPath != tcCPath.withNewMappedPath(tcC->compilerCommand())) { addWarning(Tr::tr("CMake configuration has a path to a C compiler set " "that does not match the compiler path " "configured in the tool chain of the kit.")); @@ -1275,7 +1274,7 @@ Tasks CMakeConfigurationKitAspect::validate(const Kit *k) const if (!tcCxx || !tcCxx->isValid()) { addWarning(Tr::tr("CMake configuration has a path to a C++ compiler set, " "even though the kit has no valid tool chain.")); - } else if (tcCxxPath != tcCxx->compilerCommand() && tcCxxPath != tcCxx->compilerCommand().onDevice(tcCxxPath)) { + } else if (tcCxxPath != tcCxx->compilerCommand() && tcCxxPath != tcCxxPath.withNewMappedPath(tcCxx->compilerCommand())) { addWarning(Tr::tr("CMake configuration has a path to a C++ compiler set " "that does not match the compiler path " "configured in the tool chain of the kit.")); diff --git a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp index 7a14143a4b9..4db0d519e76 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp @@ -67,8 +67,8 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList & return; } - const FilePath sourceDirectory = parameters.sourceDirectory.onDevice(cmakeExecutable); - const FilePath buildDirectory = parameters.buildDirectory.onDevice(cmakeExecutable); + const FilePath sourceDirectory = cmakeExecutable.withNewMappedPath(parameters.sourceDirectory); + const FilePath buildDirectory = cmakeExecutable.withNewMappedPath(parameters.buildDirectory); if (!buildDirectory.exists()) { const QString msg = ::CMakeProjectManager::Tr::tr( diff --git a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp index ab79be78aea..cab07381ccd 100644 --- a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp +++ b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp @@ -264,7 +264,7 @@ QList generateBuildTargets(const PreprocessedData &input, continue; const FilePath buildDir = haveLibrariesRelativeToBuildDirectory ? buildDirectory : currentBuildDir; - FilePath tmp = buildDir.resolvePath(FilePath::fromUserInput(part).onDevice(buildDir)); + FilePath tmp = buildDir.resolvePath(buildDir.withNewPath(part)); if (f.role == "libraries") tmp = tmp.parentDir(); diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index d972413bbb0..7f0dc8c3f42 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -886,8 +886,8 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, AllowTerminal allowTerm Runnable inferior = runControl->runnable(); const FilePath &debuggerExecutable = m_runParameters.debugger.command.executable(); - inferior.command.setExecutable(inferior.command.executable().onDevice(debuggerExecutable)); - inferior.workingDirectory = inferior.workingDirectory.onDevice(debuggerExecutable); + inferior.command.setExecutable(debuggerExecutable.withNewMappedPath(inferior.command.executable())); + inferior.workingDirectory = debuggerExecutable.withNewMappedPath(inferior.workingDirectory); // Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...) inferior.workingDirectory = inferior.workingDirectory.normalizedPathName(); m_runParameters.inferior = inferior; diff --git a/src/plugins/debugger/stackframe.cpp b/src/plugins/debugger/stackframe.cpp index 7008900aab2..7ba504d5caf 100644 --- a/src/plugins/debugger/stackframe.cpp +++ b/src/plugins/debugger/stackframe.cpp @@ -74,7 +74,7 @@ StackFrame StackFrame::parseFrame(const GdbMi &frameMi, const DebuggerRunParamet frame.function = frameMi["function"].data(); frame.module = frameMi["module"].data(); const FilePath debugger = rp.debugger.command.executable(); - const FilePath onDevicePath = FilePath::fromUserInput(frameMi["file"].data()).onDevice(debugger); + const FilePath onDevicePath = debugger.withNewPath(frameMi["file"].data()).cleanPath(); frame.file = onDevicePath.localSource().value_or(onDevicePath); frame.line = frameMi["line"].toInt(); frame.address = frameMi["address"].toAddress(); diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index c001cfb0b10..5e8fc5c521e 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -106,7 +106,7 @@ private: CommandLine createFallbackCommand(const CommandLine &cmdLine) { CommandLine result = cmdLine; - result.setExecutable(cmdLine.executable().onDevice(m_devicePath)); + result.setExecutable(m_devicePath.withNewPath(cmdLine.executable().path())); return result; } @@ -497,7 +497,7 @@ CommandLine DockerDevicePrivate::withDockerExecCmd(const CommandLine &cmd, } if (workDir && !workDir->isEmpty()) - dockerCmd.addArgs({"-w", workDir->onDevice(q->rootPath()).nativePath()}); + dockerCmd.addArgs({"-w", q->rootPath().withNewMappedPath(*workDir).nativePath()}); dockerCmd.addArg(m_container); diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index 81811852a53..08d7429acd6 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -2114,7 +2114,7 @@ FilePath Client::serverUriToHostPath(const LanguageServerProtocol::DocumentUri & DocumentUri Client::hostPathToServerUri(const Utils::FilePath &path) const { return DocumentUri::fromFilePath(path, [&](const Utils::FilePath &clientPath) { - return clientPath.onDevice(d->m_serverDeviceTemplate); + return d->m_serverDeviceTemplate.withNewPath(clientPath.path()); }); } diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp index c838458aa5d..30036fcdc5c 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.cpp +++ b/src/plugins/projectexplorer/abstractprocessstep.cpp @@ -306,7 +306,7 @@ bool AbstractProcessStep::setupProcessParameters(ProcessParameters *params) cons const bool looksGood = executable.isEmpty() || executable.ensureReachable(workingDirectory); QTC_ASSERT(looksGood, return false); - params->setWorkingDirectory(workingDirectory.onDevice(executable)); + params->setWorkingDirectory(executable.withNewPath(workingDirectory.path())); return true; } diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index f8e99c32444..b145ba56b6b 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -196,7 +196,7 @@ HeaderPaths GccToolChain::gccHeaderPaths(const FilePath &gcc, } const FilePath headerPath - = FilePath::fromString(QString::fromUtf8(line)).onDevice(gcc).canonicalPath(); + = gcc.withNewPath(QString::fromUtf8(line)).canonicalPath(); if (!headerPath.isEmpty()) builtInHeaderPaths.append({headerPath, thisHeaderKind}); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index cdb6d708c4d..928ca9db58d 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -391,7 +391,7 @@ Runnable RunConfiguration::runnable() const Runnable r; r.command = commandLine(); if (auto workingDirectoryAspect = aspect()) - r.workingDirectory = workingDirectoryAspect->workingDirectory().onDevice(r.command.executable()); + r.workingDirectory = r.command.executable().withNewPath(workingDirectoryAspect->workingDirectory().path()); if (auto environmentAspect = aspect()) r.environment = environmentAspect->environment(); if (m_runnableModifier) diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index 7e278d353e9..c64fa4431aa 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -624,7 +624,7 @@ FilePath ExecutableAspect::executable() const : m_executable.filePath(); if (const IDevice::ConstPtr dev = executionDevice(m_target, m_selector)) - exe = exe.onDevice(dev->rootPath()); + exe = dev->rootPath().withNewMappedPath(exe); return exe; } diff --git a/src/plugins/python/pysidebuildconfiguration.cpp b/src/plugins/python/pysidebuildconfiguration.cpp index ce37bb67b32..eae9b4eeeae 100644 --- a/src/plugins/python/pysidebuildconfiguration.cpp +++ b/src/plugins/python/pysidebuildconfiguration.cpp @@ -63,7 +63,7 @@ PySideBuildStep::PySideBuildStep(BuildStepList *bsl, Id id) setCommandLineProvider([this] { return CommandLine(m_pysideProject->filePath(), {"build"}); }); setWorkingDirectoryProvider([this] { - return target()->project()->projectDirectory().onDevice(m_pysideProject->filePath()); + return m_pysideProject->filePath().withNewMappedPath(target()->project()->projectDirectory()); // FIXME: new path needed? }); setEnvironmentModifier([this](Environment &env) { env.prependOrSetPath(m_pysideProject->filePath().parentDir()); diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index 2163e2b7ed6..dc383961172 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -216,7 +216,7 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Id id) currentInterpreterChanged(); setRunnableModifier([](Runnable &r) { - r.workingDirectory = r.workingDirectory.onDevice(r.command.executable()); + r.workingDirectory = r.command.executable().withNewMappedPath(r.workingDirectory); // FIXME: Needed? }); connect(PySideInstaller::instance(), &PySideInstaller::pySideInstalled, this, @@ -280,12 +280,12 @@ void PythonRunConfigurationPrivate::handlePySidePackageInfo(const PipPackageInfo = OsSpecificAspects::withExecutableSuffix(python.osType(), "pyside6-uic"); for (const FilePath &file : files) { if (file.fileName() == pySide6ProjectName) { - result.pySideProjectPath = location.resolvePath(file).onDevice(python); + result.pySideProjectPath = python.withNewMappedPath(location.resolvePath(file)); result.pySideProjectPath = result.pySideProjectPath.cleanPath(); if (!result.pySideUicPath.isEmpty()) return result; } else if (file.fileName() == pySide6UicName) { - result.pySideUicPath = location.resolvePath(file).onDevice(python); + result.pySideUicPath = python.withNewMappedPath(location.resolvePath(file)); result.pySideUicPath = result.pySideUicPath.cleanPath(); if (!result.pySideProjectPath.isEmpty()) return result; diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 2012fb7470a..c96f310e0bc 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -1253,7 +1253,7 @@ void QtVersionPrivate::updateVersionInfo() m_qmakeIsExecutable = true; auto fileProperty = [this](const QByteArray &name) { - return FilePath::fromUserInput(qmakeProperty(name)).onDevice(m_qmakeCommand); + return m_qmakeCommand.withNewPath(qmakeProperty(name)).cleanPath(); }; m_data.prefix = fileProperty("QT_INSTALL_PREFIX"); @@ -1774,7 +1774,7 @@ FilePath QtVersionPrivate::mkspecDirectoryFromVersionInfo(const QHash &versionInfo, diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index d986ee88dd8..96bc176cfa3 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -821,7 +821,7 @@ class ShellThreadHandler : public QObject CommandLine createFallbackCommand(const CommandLine &cmdLine) override { CommandLine result = cmdLine; - result.setExecutable(cmdLine.executable().onDevice(m_devicePath)); + result.setExecutable(m_devicePath.withNewMappedPath(cmdLine.executable())); // Needed? return result; } diff --git a/src/plugins/remotelinux/makeinstallstep.cpp b/src/plugins/remotelinux/makeinstallstep.cpp index 79c42bdf107..b078dce1a91 100644 --- a/src/plugins/remotelinux/makeinstallstep.cpp +++ b/src/plugins/remotelinux/makeinstallstep.cpp @@ -145,7 +145,7 @@ bool MakeInstallStep::init() if (!MakeStep::init()) return false; - const FilePath rootDir = installRoot().onDevice(makeCommand()); + const FilePath rootDir = makeCommand().withNewPath(installRoot().path()); // FIXME: Needed? if (rootDir.isEmpty()) { emit addTask(BuildSystemTask(Task::Error, Tr::tr("You must provide an install root."))); return false; @@ -191,7 +191,7 @@ bool MakeInstallStep::init() void MakeInstallStep::finish(ProcessResult result) { if (isSuccess(result)) { - const FilePath rootDir = installRoot().onDevice(makeCommand()); + const FilePath rootDir = makeCommand().withNewPath(installRoot().path()); // FIXME: Needed? m_deploymentData = DeploymentData(); m_deploymentData.setLocalInstallRoot(rootDir); diff --git a/src/plugins/valgrind/callgrindengine.cpp b/src/plugins/valgrind/callgrindengine.cpp index 51ec76a1305..d238cb89e0c 100644 --- a/src/plugins/valgrind/callgrindengine.cpp +++ b/src/plugins/valgrind/callgrindengine.cpp @@ -201,7 +201,7 @@ void CallgrindToolRunner::run(Option option) this, &CallgrindToolRunner::controllerProcessDone); const FilePath control = - FilePath(CALLGRIND_CONTROL_BINARY).onDevice(m_valgrindRunnable.command.executable()); + m_valgrindRunnable.command.executable().withNewPath(CALLGRIND_CONTROL_BINARY); m_controllerProcess->setCommand({control, {toOptionString(option), QString::number(m_pid)}}); m_controllerProcess->setWorkingDirectory(m_valgrindRunnable.workingDirectory); m_controllerProcess->setEnvironment(m_valgrindRunnable.environment); diff --git a/tests/auto/utils/filepath/tst_filepath.cpp b/tests/auto/utils/filepath/tst_filepath.cpp index fa586ad5bcd..64888937dec 100644 --- a/tests/auto/utils/filepath/tst_filepath.cpp +++ b/tests/auto/utils/filepath/tst_filepath.cpp @@ -87,8 +87,8 @@ private slots: void startsWithDriveLetter(); void startsWithDriveLetter_data(); - void onDevice_data(); - void onDevice(); + void withNewMappedPath_data(); + void withNewMappedPath(); void stringAppended(); void stringAppended_data(); @@ -1333,7 +1333,7 @@ void tst_filepath::startsWithDriveLetter() QCOMPARE(path.startsWithDriveLetter(), expected); } -void tst_filepath::onDevice_data() +void tst_filepath::withNewMappedPath_data() { QTest::addColumn("path"); QTest::addColumn("templatePath"); @@ -1350,13 +1350,13 @@ void tst_filepath::onDevice_data() << FilePath("/a/b") << FilePath("docker://1234/c/d") << FilePath("docker://1234/a/b"); } -void tst_filepath::onDevice() +void tst_filepath::withNewMappedPath() { QFETCH(FilePath, path); QFETCH(FilePath, templatePath); QFETCH(FilePath, expected); - QCOMPARE(path.onDevice(templatePath), expected); + QCOMPARE(templatePath.withNewMappedPath(path), expected); } void tst_filepath::stringAppended_data()