diff options
Diffstat (limited to 'src/corelib/io/qresource.cpp')
-rw-r--r-- | src/corelib/io/qresource.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index af0b9429af..fe19a8f4f4 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -78,6 +78,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // Symbols used by code generated by RCC. // They cause compilation errors if the RCC content couldn't // be interpreted by this QtCore version. @@ -125,7 +127,7 @@ public: const QChar *m_data; qsizetype m_len; qsizetype m_pos = 0; - QChar m_splitChar = QLatin1Char('/'); + QChar m_splitChar = u'/'; }; // resource glue @@ -189,7 +191,7 @@ static QString cleanPath(const QString &_path) QString path = QDir::cleanPath(_path); // QDir::cleanPath does not remove two trailing slashes under _Windows_ // due to support for UNC paths. Remove those manually. - if (path.startsWith(QLatin1String("//"))) + if (path.startsWith("//"_L1)) path.remove(0, 1); return path; } @@ -381,26 +383,26 @@ void QResourcePrivate::ensureInitialized() const if (!related.isEmpty()) return; QResourcePrivate *that = const_cast<QResourcePrivate *>(this); - if (fileName == QLatin1String(":")) - that->fileName += QLatin1Char('/'); + if (fileName == ":"_L1) + that->fileName += u'/'; that->absoluteFilePath = fileName; - if (!that->absoluteFilePath.startsWith(QLatin1Char(':'))) - that->absoluteFilePath.prepend(QLatin1Char(':')); + if (!that->absoluteFilePath.startsWith(u':')) + that->absoluteFilePath.prepend(u':'); QStringView path(fileName); - if (path.startsWith(QLatin1Char(':'))) + if (path.startsWith(u':')) path = path.mid(1); - if (path.startsWith(QLatin1Char('/'))) { + if (path.startsWith(u'/')) { that->load(path.toString()); } else { const auto locker = qt_scoped_lock(resourceMutex()); QStringList searchPaths = *resourceSearchPaths(); - searchPaths << QLatin1String(""); + searchPaths << ""_L1; for (int i = 0; i < searchPaths.size(); ++i) { - const QString searchPath(searchPaths.at(i) + QLatin1Char('/') + path); + const QString searchPath(searchPaths.at(i) + u'/' + path); if (that->load(searchPath)) { - that->absoluteFilePath = QLatin1Char(':') + searchPath; + that->absoluteFilePath = u':' + searchPath; break; } } @@ -414,7 +416,7 @@ void QResourcePrivate::ensureChildren() const return; QString path = absoluteFilePath, k; - if (path.startsWith(QLatin1Char(':'))) + if (path.startsWith(u':')) path = path.mid(1); QDuplicateTracker<QString> kids(related.size()); QString cleaned = cleanPath(path); @@ -808,14 +810,14 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const QString root = mappingRoot(); if (!root.isEmpty()) { if (root == path) { - path = QLatin1Char('/'); + path = u'/'; } else { - if (!root.endsWith(QLatin1Char('/'))) - root += QLatin1Char('/'); + if (!root.endsWith(u'/')) + root += u'/'; if (path.size() >= root.size() && path.startsWith(root)) path = path.mid(root.length() - 1); if (path.isEmpty()) - path = QLatin1Char('/'); + path = u'/'; } } } @@ -823,7 +825,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const qDebug() << "!!!!" << "START" << path << locale.territory() << locale.language(); #endif - if (path == QLatin1String("/")) + if (path == "/"_L1) return 0; // the root node is always first @@ -1228,7 +1230,7 @@ bool QDynamicFileResourceRoot::registerSelf(const QString &f) static QString qt_resource_fixResourceRoot(QString r) { if (!r.isEmpty()) { - if (r.startsWith(QLatin1Char(':'))) + if (r.startsWith(u':')) r = r.mid(1); if (!r.isEmpty()) r = QDir::cleanPath(r); @@ -1249,7 +1251,7 @@ static QString qt_resource_fixResourceRoot(QString r) bool QResource::registerResource(const QString &rccFilename, const QString &resourceRoot) { QString r = qt_resource_fixResourceRoot(resourceRoot); - if (!r.isEmpty() && r[0] != QLatin1Char('/')) { + if (!r.isEmpty() && r[0] != u'/') { qWarning("QDir::registerResource: Registering a resource [%ls] must be rooted in an " "absolute path (start with /) [%ls]", qUtf16Printable(rccFilename), qUtf16Printable(resourceRoot)); @@ -1318,7 +1320,7 @@ bool QResource::unregisterResource(const QString &rccFilename, const QString &re bool QResource::registerResource(const uchar *rccData, const QString &resourceRoot) { QString r = qt_resource_fixResourceRoot(resourceRoot); - if (!r.isEmpty() && r[0] != QLatin1Char('/')) { + if (!r.isEmpty() && r[0] != u'/') { qWarning("QDir::registerResource: Registering a resource [%p] must be rooted in an " "absolute path (start with /) [%ls]", rccData, qUtf16Printable(resourceRoot)); @@ -1512,7 +1514,7 @@ QAbstractFileEngine::FileFlags QResourceFileEngine::fileFlags(QAbstractFileEngin } if (type & FlagsMask) { ret |= ExistsFlag; - if (d->resource.absoluteFilePath() == QLatin1String(":/")) + if (d->resource.absoluteFilePath() == ":/"_L1) ret |= RootFlag; } return ret; @@ -1522,24 +1524,24 @@ QString QResourceFileEngine::fileName(FileName file) const { Q_D(const QResourceFileEngine); if (file == BaseName) { - int slash = d->resource.fileName().lastIndexOf(QLatin1Char('/')); + int slash = d->resource.fileName().lastIndexOf(u'/'); if (slash == -1) return d->resource.fileName(); return d->resource.fileName().mid(slash + 1); } else if (file == PathName || file == AbsolutePathName) { const QString path = (file == AbsolutePathName) ? d->resource.absoluteFilePath() : d->resource.fileName(); - const int slash = path.lastIndexOf(QLatin1Char('/')); + const int slash = path.lastIndexOf(u'/'); if (slash == -1) - return QLatin1String(":"); + return ":"_L1; else if (slash <= 1) - return QLatin1String(":/"); + return ":/"_L1; return path.left(slash); } else if (file == CanonicalName || file == CanonicalPathName) { const QString absoluteFilePath = d->resource.absoluteFilePath(); if (file == CanonicalPathName) { - const int slash = absoluteFilePath.lastIndexOf(QLatin1Char('/')); + const int slash = absoluteFilePath.lastIndexOf(u'/'); if (slash != -1) return absoluteFilePath.left(slash); } |