summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-03-03 17:14:24 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-03-06 18:46:54 +0100
commit9e01827193a4aaafc7bb1a92c15c4edcee3bee00 (patch)
treef0b0d6dc7fdbb71cc3474c6e70b6b840a9b291de /src
parent34b5e38f207e092f89bb18aa0e69336b70de5247 (diff)
Add QFileInfo::isAlias() to reflect whether the file is a macOS alias
Change-Id: I772066d0d8e69893f7c4aee1cd2305d46d5834c4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfileinfo.cpp27
-rw-r--r--src/corelib/io/qfileinfo.h1
2 files changed, 26 insertions, 2 deletions
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index fa6cd33ec4..5e2b5eb4ad 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -1118,8 +1118,8 @@ bool QFileInfo::isSymLink() const
opens the \l{symLinkTarget()}{link's target}.
In contrast to isSymLink(), false will be returned for shortcuts
- (\c *.lnk files) on Windows and aliases on \macos.
- Use QFileInfo::isShortcut() on Windows instead.
+ (\c *.lnk files) on Windows and aliases on \macos. Use QFileInfo::isShortcut()
+ and QFileInfo::isAlias() instead.
\note If the symlink points to a non existing file, exists() returns
false.
@@ -1162,6 +1162,29 @@ bool QFileInfo::isShortcut() const
[d]() { return d->getFileFlags(QAbstractFileEngine::LinkType); });
}
+/*!
+ Returns \c true if this object points to an alias;
+ otherwise returns \c false.
+
+ \since 6.4
+
+ Aliases only exist on \macos. They are treated as regular files, so
+ opening an alias will open the file itself. In order to open the file
+ or directory an alias references use symLinkTarget().
+
+ \note Even if an alias points to a non existing file,
+ isAlias() returns true.
+
+ \sa isFile(), isDir(), isSymLink(), symLinkTarget()
+*/
+bool QFileInfo::isAlias() const
+{
+ Q_D(const QFileInfo);
+ return d->checkAttribute<bool>(
+ QFileSystemMetaData::LegacyLinkType,
+ [d]() { return d->metaData.isAlias(); },
+ [d]() { return d->getFileFlags(QAbstractFileEngine::LinkType); });
+}
/*!
\since 5.15
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index f2260db410..ac6211fcf9 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -156,6 +156,7 @@ public:
bool isSymLink() const;
bool isSymbolicLink() const;
bool isShortcut() const;
+ bool isAlias() const;
bool isJunction() const;
bool isRoot() const;
bool isBundle() const;