forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user