Utils: Add convenience functions FilePath::path{List,Component}Separator

Change-Id: Ib00aace2d5e98fa69a5a23b3950e560aefc662f6
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2022-12-13 09:22:58 +01:00
parent eeeb5f0aad
commit a1711fc5ba
2 changed files with 20 additions and 0 deletions

View File

@@ -1420,6 +1420,24 @@ Qt::CaseSensitivity FilePath::caseSensitivity() const
return Qt::CaseSensitive; return Qt::CaseSensitive;
} }
/*!
* \brief Returns the separator of path components for this path.
* \returns The path separator of the path.
*/
QChar FilePath::pathComponentSeparator() const
{
return osType() == OsTypeWindows ? u'\\' : u'/';
}
/*!
* \brief Returns the path list separator for the device this path belongs to.
* \returns The path list separator of the device for this path
*/
QChar FilePath::pathListSeparator() const
{
return osType() == OsTypeWindows ? u';' : u':';
}
/*! /*!
* \brief Recursively resolves symlinks if this is a symlink. * \brief Recursively resolves symlinks if this is a symlink.
* To resolve symlinks anywhere in the path, see canonicalPath. * To resolve symlinks anywhere in the path, see canonicalPath.

View File

@@ -140,6 +140,8 @@ public:
[[nodiscard]] FilePath operator/(const QString &str) const; [[nodiscard]] FilePath operator/(const QString &str) const;
Qt::CaseSensitivity caseSensitivity() const; Qt::CaseSensitivity caseSensitivity() const;
QChar pathComponentSeparator() const;
QChar pathListSeparator() const;
void clear(); void clear();
bool isEmpty() const; bool isEmpty() const;