summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystementry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qfilesystementry.cpp')
-rw-r--r--src/corelib/io/qfilesystementry.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp
index 6a655391be..ac1691d30e 100644
--- a/src/corelib/io/qfilesystementry.cpp
+++ b/src/corelib/io/qfilesystementry.cpp
@@ -14,6 +14,10 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
+// Assigned to m_lastSeparator and m_firstDotInFileName to indicate resolveFilePath()
+// hasn't been called yet
+constexpr int Uninitialized = -2;
+
#ifdef Q_OS_WIN
static bool isUncRoot(const QString &server)
{
@@ -51,8 +55,8 @@ QFileSystemEntry::QFileSystemEntry()
*/
QFileSystemEntry::QFileSystemEntry(const QString &filePath)
: m_filePath(QDir::fromNativeSeparators(filePath)),
- m_lastSeparator(-2),
- m_firstDotInFileName(-2),
+ m_lastSeparator(Uninitialized),
+ m_firstDotInFileName(Uninitialized),
m_lastDotInFileName(0)
{
}
@@ -64,8 +68,8 @@ QFileSystemEntry::QFileSystemEntry(const QString &filePath)
*/
QFileSystemEntry::QFileSystemEntry(const QString &filePath, FromInternalPath /* dummy */)
: m_filePath(filePath),
- m_lastSeparator(-2),
- m_firstDotInFileName(-2),
+ m_lastSeparator(Uninitialized),
+ m_firstDotInFileName(Uninitialized),
m_lastDotInFileName(0)
{
}
@@ -76,8 +80,8 @@ QFileSystemEntry::QFileSystemEntry(const QString &filePath, FromInternalPath /*
*/
QFileSystemEntry::QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath /* dummy */)
: m_nativeFilePath(nativeFilePath),
- m_lastSeparator(-2),
- m_firstDotInFileName(-2),
+ m_lastSeparator(Uninitialized),
+ m_firstDotInFileName(Uninitialized),
m_lastDotInFileName(0)
{
}
@@ -85,8 +89,8 @@ QFileSystemEntry::QFileSystemEntry(const NativePath &nativeFilePath, FromNativeP
QFileSystemEntry::QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath)
: m_filePath(QDir::fromNativeSeparators(filePath)),
m_nativeFilePath(nativeFilePath),
- m_lastSeparator(-2),
- m_firstDotInFileName(-2),
+ m_lastSeparator(Uninitialized),
+ m_firstDotInFileName(Uninitialized),
m_lastDotInFileName(0)
{
}
@@ -312,7 +316,7 @@ bool QFileSystemEntry::isEmpty() const
void QFileSystemEntry::findLastSeparator() const
{
- if (m_lastSeparator == -2) {
+ if (m_lastSeparator == Uninitialized) {
resolveFilePath();
m_lastSeparator = m_filePath.lastIndexOf(u'/');
}
@@ -320,7 +324,7 @@ void QFileSystemEntry::findLastSeparator() const
void QFileSystemEntry::findFileNameSeparators() const
{
- if (m_firstDotInFileName == -2) {
+ if (m_firstDotInFileName == Uninitialized) {
resolveFilePath();
int firstDotInFileName = -1;
int lastDotInFileName = -1;