summaryrefslogtreecommitdiff
path: root/src/plugins/docker/dockerdevice.cpp
diff options
context:
space:
mode:
authorMarcus Tillmanns <marcus.tillmanns@qt.io>2022-12-01 07:59:35 +0100
committerMarcus Tillmanns <marcus.tillmanns@qt.io>2022-12-16 12:27:49 +0000
commit0aeec80eeb16f9412647124c2ebe3c4499fb0684 (patch)
tree494c4ac8e634082e7b031a4233c517650bfab45d /src/plugins/docker/dockerdevice.cpp
parent2ffa843d404f47693325b7da0f887722f1f114dd (diff)
downloadqt-creator-0aeec80eeb16f9412647124c2ebe3c4499fb0684.tar.gz
Docker: Add Filepath::localSource()
FilePath::localSource can return a filepath that represents a local version of a remote file. It is used to let the debugger select the local version of a file when debugging a remote target. Change-Id: Ieb934ef0d454e8ff55e71df41dca825974d85da7 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/docker/dockerdevice.cpp')
-rw-r--r--src/plugins/docker/dockerdevice.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp
index c37e2d106e..a71ccfef50 100644
--- a/src/plugins/docker/dockerdevice.cpp
+++ b/src/plugins/docker/dockerdevice.cpp
@@ -144,6 +144,7 @@ public:
void changeMounts(QStringList newMounts);
bool ensureReachable(const FilePath &other);
void shutdown();
+ expected_str<FilePath> localSource(const FilePath &other) const;
QString containerId() { return m_container; }
DockerDeviceData data() { return m_data; }
@@ -828,6 +829,11 @@ bool DockerDevice::ensureReachable(const FilePath &other) const
return d->ensureReachable(other.parentDir());
}
+expected_str<FilePath> DockerDevice::localSource(const Utils::FilePath &other) const
+{
+ return d->localSource(other);
+}
+
Environment DockerDevice::systemEnvironment() const
{
return d->environment();
@@ -1125,6 +1131,27 @@ void DockerDevicePrivate::changeMounts(QStringList newMounts)
}
}
+expected_str<FilePath> DockerDevicePrivate::localSource(const FilePath &other) const
+{
+ const auto devicePath = FilePath::fromString(other.path());
+ for (const TemporaryMountInfo &info : m_temporaryMounts) {
+ if (devicePath.isChildOf(info.containerPath)) {
+ const FilePath relativePath = devicePath.relativeChildPath(info.containerPath);
+ return info.path.pathAppended(relativePath.path());
+ }
+ }
+
+ for (const QString &mount : m_data.mounts) {
+ const FilePath mountPoint = FilePath::fromString(mount);
+ if (devicePath.isChildOf(mountPoint)) {
+ const FilePath relativePath = devicePath.relativeChildPath(mountPoint);
+ return mountPoint.pathAppended(relativePath.path());
+ }
+ }
+
+ return make_unexpected(Tr::tr("localSource: No mount point found for %1").arg(other.toString()));
+}
+
bool DockerDevicePrivate::ensureReachable(const FilePath &other)
{
for (const QString &mount : m_data.mounts) {