From 34b5e38f207e092f89bb18aa0e69336b70de5247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 3 Mar 2022 18:05:46 +0100 Subject: [PATCH] Distinguish macOS aliases from normal symbolic links The deprecated Carbon function FSIsAliasFile() returned isAlias only for actual aliases, whereas the replacement CFURLCopyResourcePropertyForKey with kCFURLIsAliasFileKey returns true for both aliases and symbolic links. Since we didn't explicitly check for AliasType in any of our internal code, or or any of the public API, the distinction did not cause any issues, but if we want to expose QFileInfo::isAlias() we need to fix this. Pick-to: 6.2 6.3 5.15 Change-Id: I29f795d55fe40898de319aa1cb0a4a1b5646bbd6 Reviewed-by: Volker Hilsheimer Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemengine_unix.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 47dd7bea7e6..3baf2d20b78 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -891,6 +891,8 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM if (!data.hasFlags(QFileSystemMetaData::DirectoryType)) what |= QFileSystemMetaData::DirectoryType; } + if (what & QFileSystemMetaData::AliasType) + what |= QFileSystemMetaData::LinkType; #endif #ifdef UF_HIDDEN if (what & QFileSystemMetaData::HiddenAttribute) { @@ -1026,8 +1028,11 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM #if defined(Q_OS_DARWIN) if (what & QFileSystemMetaData::AliasType) { - if (entryErrno == 0 && hasResourcePropertyFlag(data, entry, kCFURLIsAliasFileKey)) - data.entryFlags |= QFileSystemMetaData::AliasType; + if (entryErrno == 0 && hasResourcePropertyFlag(data, entry, kCFURLIsAliasFileKey)) { + // kCFURLIsAliasFileKey includes symbolic links, so filter those out + if (!(data.entryFlags & QFileSystemMetaData::LinkType)) + data.entryFlags |= QFileSystemMetaData::AliasType; + } data.knownFlagsMask |= QFileSystemMetaData::AliasType; }