diff options
Diffstat (limited to 'src/corelib/io/qfilesystemiterator_win.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemiterator_win.cpp | 71 |
1 files changed, 17 insertions, 54 deletions
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 1b65ae3c09..7644a1a078 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qfilesystemiterator_p.h" #include "qfilesystemengine_p.h" @@ -46,30 +10,29 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + bool done = true; -QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, - const QStringList &nameFilters, QDirIterator::IteratorFlags flags) - : nativePath(entry.nativeFilePath()) - , dirPath(entry.filePath()) +QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters) + : dirPath(entry.filePath()) + , nativePath(entry.nativeFilePath()) , findFileHandle(INVALID_HANDLE_VALUE) , uncFallback(false) , uncShareIndex(0) , onlyDirs(false) { - Q_UNUSED(nameFilters); - Q_UNUSED(flags); - if (nativePath.endsWith(QLatin1String(".lnk"))) { + if (nativePath.endsWith(u".lnk"_s) && !QFileSystemEngine::isDirPath(dirPath, nullptr)) { QFileSystemMetaData metaData; QFileSystemEntry link = QFileSystemEngine::getLinkTarget(entry, metaData); nativePath = link.nativeFilePath(); } - if (!nativePath.endsWith(QLatin1Char('\\'))) - nativePath.append(QLatin1Char('\\')); - nativePath.append(QLatin1Char('*')); + if (!nativePath.endsWith(u'\\')) + nativePath.append(u'\\'); + nativePath.append(u'*'); // In MSVC2015+ case we prepend //?/ for longer file-name support - if (!dirPath.endsWith(QLatin1Char('/'))) - dirPath.append(QLatin1Char('/')); + if (!dirPath.endsWith(u'/')) + dirPath.append(u'/'); if ((filters & (QDir::Dirs|QDir::Drives)) && (!(filters & (QDir::Files)))) onlyDirs = true; } @@ -97,10 +60,10 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa findFileHandle = FindFirstFileEx((const wchar_t *)nativePath.utf16(), FINDEX_INFO_LEVELS(infoLevel), &findData, FINDEX_SEARCH_OPS(searchOps), 0, dwAdditionalFlags); if (findFileHandle == INVALID_HANDLE_VALUE) { - if (nativePath.startsWith(QLatin1String("\\\\?\\UNC\\"))) { - const auto parts = QStringView{nativePath}.split(QLatin1Char('\\'), Qt::SkipEmptyParts); + if (nativePath.startsWith("\\\\?\\UNC\\"_L1)) { + const auto parts = QStringView{nativePath}.split(u'\\', Qt::SkipEmptyParts); if (parts.count() == 4 && QFileSystemEngine::uncListSharesOnServer( - QLatin1String("\\\\") + parts.at(2), &uncShares)) { + "\\\\"_L1 + parts.at(2), &uncShares)) { if (uncShares.isEmpty()) return false; // No shares found in the server uncFallback = true; @@ -129,7 +92,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa QString fileName = QString::fromWCharArray(findData.cFileName); fileEntry = QFileSystemEntry(dirPath + fileName); metaData = QFileSystemMetaData(); - if (!fileName.endsWith(QLatin1String(".lnk"))) { + if (!fileName.endsWith(".lnk"_L1)) { metaData.fillFromFindData(findData, true); } return true; |