Utils: Add helper function

Recurring pattern for local Windows paths.

Change-Id: I4deb7e42012a06281c6081a63415eaeb60203157
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2021-08-05 09:01:11 +02:00
parent 9810d3aca7
commit 1e901c5d61
2 changed files with 10 additions and 0 deletions

View File

@@ -993,6 +993,15 @@ bool FilePath::endsWith(const QString &s) const
return m_data.endsWith(s, caseSensitivity());
}
/// \returns whether FilePath starts with a drive letter
/// \note defaults to \c false if it is a non-Windows host or represents a path on device
bool FilePath::startsWithDriveLetter() const
{
if (needsDevice() || !HostOsInfo::isWindowsHost())
return false;
return m_data.length() >= 2 && m_data.at(0).isLetter() && m_data.at(1) == ':';
}
/// \returns the relativeChildPath of FilePath to parent if FilePath is a child of parent
/// \note returns a empty FilePath if FilePath is not a child of parent
/// That is, this never returns a path starting with "../"