diff options
author | hjk <[email protected]> | 2021-06-29 15:57:41 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2021-06-30 11:11:10 +0000 |
commit | 4a8c222c183f2576975593f7cf7d756f8cb0aa03 (patch) | |
tree | 98f82fbe7a74e2ec74584e769c2e627a571e7aff /src/libs/utils/fileutils.cpp | |
parent | 4c3bbba75c8d0a4941c672f1a5a4f89d940f1183 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 296a4f398e3..1f5a7b7cbc1 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -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. |