diff options
Diffstat (limited to 'src/corelib/io/qfilesystementry.cpp')
-rw-r--r-- | src/corelib/io/qfilesystementry.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index b507ad8ba0..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) { } @@ -303,11 +307,16 @@ bool QFileSystemEntry::isRoot() const return isRootPath(m_filePath); } +bool QFileSystemEntry::isEmpty() const +{ + return m_filePath.isEmpty() && m_nativeFilePath.isEmpty(); +} + // private methods void QFileSystemEntry::findLastSeparator() const { - if (m_lastSeparator == -2) { + if (m_lastSeparator == Uninitialized) { resolveFilePath(); m_lastSeparator = m_filePath.lastIndexOf(u'/'); } @@ -315,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; |