Utils: Add FilePath::symLinkTarget

And implement it for the docker device.

This replaces the previous unused and not really implemented
FilePath::resolveSymLinkTarget.

Change-Id: I9dcb4f8276dbb88b21959276da0d50135742fba0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-06-29 15:57:41 +02:00
parent 4c3bbba75c
commit 4a8c222c18
7 changed files with 46 additions and 7 deletions

View File

@@ -391,13 +391,6 @@ FilePath FilePath::resolvePath(const QString &fileName) const
return FilePath::fromString(QDir::cleanPath(toString() + QLatin1Char('/') + fileName));
}
FilePath FilePath::resolveSymlinkTarget() const
{
// FIXME: implement
QTC_CHECK(false);
return *this;
}
FilePath FilePath::cleanPath() const
{
FilePath result = *this;
@@ -1009,6 +1002,19 @@ bool FilePath::needsDevice() const
return !m_scheme.isEmpty();
}
/// \returns an empty FilePath if this is not a symbolic linl
FilePath FilePath::symLinkTarget() const
{
if (needsDevice()) {
QTC_ASSERT(s_deviceHooks.symLinkTarget, return {});
return s_deviceHooks.symLinkTarget(*this);
}
const QFileInfo info(m_data);
if (!info.isSymLink())
return {};
return FilePath::fromString(info.symLinkTarget());
}
/// Find the parent directory of a given directory.