summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemengine_unix.cpp
diff options
context:
space:
mode:
authorWang Fei <wangfeia@uniontech.com>2021-11-16 13:17:39 +0800
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2022-12-23 06:26:44 +0100
commit936cae6b53e8982fb087458745e06721d35341ef (patch)
tree75dfa407218049d42262f9da0430e94918c57ec8 /src/corelib/io/qfilesystemengine_unix.cpp
parent8844c6ef379f466a12a5f4981c78bdb990d92db8 (diff)
Add QFileInfo::readSymLink() to read the raw link path
The existing symLinkTarget() always resolves the symlink target to an absolute path; readSymLink() provides access to the relative path when that is how the symlink references its target. [ChangeLog][QtCore][QFileInfo] Added readSymLink() to read the symlink's raw target, without resolving to an absolute path. Fixes: QTBUG-96761 Change-Id: I360e55f1a3bdb00e2966229ea8de78cf29a29417 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index daa11ff6b2..f420a0086e 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -629,6 +629,16 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
}
//static
+QFileSystemEntry QFileSystemEngine::getRawLinkPath(const QFileSystemEntry &link,
+ QFileSystemMetaData &data)
+{
+ Q_UNUSED(data)
+ const QByteArray path = qt_readlink(link.nativeFilePath().constData());
+ const QString ret = QFile::decodeName(path);
+ return QFileSystemEntry(ret);
+}
+
+//static
QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
{
Q_CHECK_FILE_NAME(entry, entry);