| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/tools/qmlcachegen/resourcefilemapper.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | ResourceFileMapper::ResourceFileMapper(const QStringList &resourceFiles) | - | ||||||
| 4 | { | - | ||||||
| 5 | for (const QString &fileName: resourceFiles) { | - | ||||||
| 6 | QFile f(fileName); | - | ||||||
| 7 | if (!f.open(QIODevice::ReadOnly)
| 0 | ||||||
| 8 | continue; never executed: continue; | 0 | ||||||
| 9 | populateFromQrcFile(f); | - | ||||||
| 10 | } never executed: end of block | 0 | ||||||
| 11 | } never executed: end of block | 0 | ||||||
| 12 | - | |||||||
| 13 | bool ResourceFileMapper::isEmpty() const | - | ||||||
| 14 | { | - | ||||||
| 15 | return never executed: qrcPathToFileSystemPath.isEmpty();return qrcPathToFileSystemPath.isEmpty();never executed: return qrcPathToFileSystemPath.isEmpty(); | 0 | ||||||
| 16 | } | - | ||||||
| 17 | - | |||||||
| 18 | QStringList ResourceFileMapper::resourcePaths(const QString &fileName) | - | ||||||
| 19 | { | - | ||||||
| 20 | const QString absPath = QDir::cleanPath(QDir::current().absoluteFilePath(fileName)); | - | ||||||
| 21 | QHashIterator<QString, QString> it(qrcPathToFileSystemPath); | - | ||||||
| 22 | QStringList resourcePaths; | - | ||||||
| 23 | while (it.hasNext()
| 0 | ||||||
| 24 | it.next(); | - | ||||||
| 25 | if (QFileInfo(it.value()) == QFileInfo(absPath)
| 0 | ||||||
| 26 | resourcePaths.append(it.key()); never executed: resourcePaths.append(it.key()); | 0 | ||||||
| 27 | } never executed: end of block | 0 | ||||||
| 28 | return never executed: resourcePaths;return resourcePaths;never executed: return resourcePaths; | 0 | ||||||
| 29 | } | - | ||||||
| 30 | - | |||||||
| 31 | QStringList ResourceFileMapper::qmlCompilerFiles() const | - | ||||||
| 32 | { | - | ||||||
| 33 | QStringList files; | - | ||||||
| 34 | for (auto it = qrcPathToFileSystemPath.constBegin(), end = qrcPathToFileSystemPath.constEnd(); | - | ||||||
| 35 | it != end
| 0 | ||||||
| 36 | const QString &qrcPath = it.key(); | - | ||||||
| 37 | const QString suffix = QFileInfo(qrcPath).suffix(); | - | ||||||
| 38 | if (suffix != ([]() noexcept -> QString { enum { Size = sizeof(u"" "qml")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "qml" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()) && suffix != ([]() noexcept -> QString { enum { Size = sizeof(u"" "js")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "js" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()))return qstring_literal_temp; | 0 | ||||||
| 39 | continue; never executed: continue; | 0 | ||||||
| 40 | files << qrcPath; dead code: files << qrcPath; | - | ||||||
| 41 | } | - | ||||||
| 42 | return never executed: files;return files;never executed: return files; | 0 | ||||||
| 43 | } | - | ||||||
| 44 | - | |||||||
| 45 | void ResourceFileMapper::populateFromQrcFile(QFile &file) | - | ||||||
| 46 | { | - | ||||||
| 47 | enum State { | - | ||||||
| 48 | InitialState, | - | ||||||
| 49 | InRCC, | - | ||||||
| 50 | InResource, | - | ||||||
| 51 | InFile | - | ||||||
| 52 | }; | - | ||||||
| 53 | State state = InitialState; | - | ||||||
| 54 | - | |||||||
| 55 | QDir qrcDir = QFileInfo(file).absoluteDir(); | - | ||||||
| 56 | - | |||||||
| 57 | QString prefix; | - | ||||||
| 58 | QString currentFileName; | - | ||||||
| 59 | QXmlStreamAttributes currentFileAttributes; | - | ||||||
| 60 | - | |||||||
| 61 | QXmlStreamReader reader(&file); | - | ||||||
| 62 | while (!reader.atEnd()
| 0 | ||||||
| 63 | switch (reader.readNext()) { | - | ||||||
| 64 | case never executed: QXmlStreamReader::StartElement:case QXmlStreamReader::StartElement:never executed: case QXmlStreamReader::StartElement: | 0 | ||||||
| 65 | if (reader.name() == ([]() noexcept -> QString { enum { Size = sizeof(u"" "RCC")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "RCC" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())) { | - | ||||||
| 66 | if (state != InitialState
| 0 | ||||||
| 67 | return; never executed: return; | 0 | ||||||
| 68 | state = InRCC; | - | ||||||
| 69 | continue; never executed: continue; | 0 | ||||||
| 70 | } else dead code: ifelsedead code: (reader.name() == ([]() noexceptif (reader.name() == ([]() noexceptdead code: -> QString { enum { Size = sizeof(u"" "qresource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "qresource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())) {if (reader.name() == ([]() noexcept | - | ||||||
| 71 | if (state != InRCC
| 0 | ||||||
| 72 | return; never executed: return; | 0 | ||||||
| 73 | state = InResource; | - | ||||||
| 74 | QXmlStreamAttributes attributes = reader.attributes(); | - | ||||||
| 75 | if (attributes.hasAttribute(([]() noexcept -> QString { enum { Size = sizeof(u"" "prefix")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "prefix" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()))
| 0 | ||||||
| 76 | prefix = attributes.value(([]() noexcept -> QString { enum { Size = sizeof(u"" "prefix")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "prefix" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }())).toString();return qstring_literal_temp;never executed: prefix = attributes.value(([]() noexcept -> QString { enum { Size = sizeof(u"" "prefix")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "prefix" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())).toString(); | 0 | ||||||
| 77 | if (!prefix.startsWith(QLatin1Char('/'))
| 0 | ||||||
| 78 | prefix.prepend(QLatin1Char('/')); never executed: prefix.prepend(QLatin1Char('/')); | 0 | ||||||
| 79 | if (!prefix.endsWith(QLatin1Char('/'))
| 0 | ||||||
| 80 | prefix.append(QLatin1Char('/')); never executed: prefix.append(QLatin1Char('/')); | 0 | ||||||
| 81 | continue; never executed: continue; | 0 | ||||||
| 82 | } else dead code: ifelsedead code: (reader.name() == ([]() noexceptif (reader.name() == ([]() noexceptdead code: -> QString { enum { Size = sizeof(u"" "file")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "file" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())) {if (reader.name() == ([]() noexcept | - | ||||||
| 83 | if (state != InResource
| 0 | ||||||
| 84 | return; never executed: return; | 0 | ||||||
| 85 | state = InFile; | - | ||||||
| 86 | currentFileAttributes = reader.attributes(); | - | ||||||
| 87 | continue; never executed: continue; | 0 | ||||||
| 88 | } | - | ||||||
| 89 | return; dead code: return; | - | ||||||
| 90 | - | |||||||
| 91 | case never executed: QXmlStreamReader::EndElement:case QXmlStreamReader::EndElement:never executed: case QXmlStreamReader::EndElement: | 0 | ||||||
| 92 | if (reader.name() == ([]() noexcept -> QString { enum { Size = sizeof(u"" "file")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "file" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())) { | - | ||||||
| 93 | if (state != InFile
| 0 | ||||||
| 94 | return; never executed: return; | 0 | ||||||
| 95 | state = InResource; | - | ||||||
| 96 | continue; never executed: continue; | 0 | ||||||
| 97 | } else dead code: ifelsedead code: (reader.name() == ([]() noexceptif (reader.name() == ([]() noexceptdead code: -> QString { enum { Size = sizeof(u"" "qresource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "qresource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())) {if (reader.name() == ([]() noexcept | - | ||||||
| 98 | if (state != InResource
| 0 | ||||||
| 99 | return; never executed: return; | 0 | ||||||
| 100 | state = InRCC; | - | ||||||
| 101 | continue; never executed: continue; | 0 | ||||||
| 102 | } else dead code: ifelsedead code: (reader.name() == ([]() noexceptif (reader.name() == ([]() noexceptdead code: -> QString { enum { Size = sizeof(u"" "RCC")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "RCC" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())) {if (reader.name() == ([]() noexcept | - | ||||||
| 103 | if (state != InRCC
| 0 | ||||||
| 104 | return; never executed: return; | 0 | ||||||
| 105 | state = InitialState; | - | ||||||
| 106 | continue; never executed: continue; | 0 | ||||||
| 107 | } | - | ||||||
| 108 | return; dead code: return; | - | ||||||
| 109 | - | |||||||
| 110 | case never executed: QXmlStreamReader::Characters:case QXmlStreamReader::Characters:never executed: {case QXmlStreamReader::Characters: | 0 | ||||||
| 111 | if (reader.isWhitespace()
| 0 | ||||||
| 112 | break; never executed: break; | 0 | ||||||
| 113 | if (state != InFile
| 0 | ||||||
| 114 | return; never executed: return; | 0 | ||||||
| 115 | currentFileName = reader.text().toString(); | - | ||||||
| 116 | if (currentFileName.isEmpty()
| 0 | ||||||
| 117 | continue; never executed: continue; | 0 | ||||||
| 118 | - | |||||||
| 119 | const QString fsPath = QDir::cleanPath(qrcDir.absoluteFilePath(currentFileName)); | - | ||||||
| 120 | - | |||||||
| 121 | if (currentFileAttributes.hasAttribute(([]() noexcept -> QString { enum { Size = sizeof(u"" "alias")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "alias" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()))
| 0 | ||||||
| 122 | currentFileName = currentFileAttributes.value(([]() noexcept -> QString { enum { Size = sizeof(u"" "alias")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "alias" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }())).toString();return qstring_literal_temp;never executed: currentFileName = currentFileAttributes.value(([]() noexcept -> QString { enum { Size = sizeof(u"" "alias")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "alias" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())).toString(); | 0 | ||||||
| 123 | - | |||||||
| 124 | currentFileName = QDir::cleanPath(currentFileName); | - | ||||||
| 125 | while (currentFileName.startsWith(QLatin1String("../"))
| 0 | ||||||
| 126 | currentFileName.remove(0, 3); never executed: currentFileName.remove(0, 3); | 0 | ||||||
| 127 | - | |||||||
| 128 | const QString qrcPath = prefix + currentFileName; | - | ||||||
| 129 | if (QFile::exists(fsPath)
| 0 | ||||||
| 130 | qrcPathToFileSystemPath.insert(qrcPath, fsPath); never executed: qrcPathToFileSystemPath.insert(qrcPath, fsPath); | 0 | ||||||
| 131 | continue; never executed: continue; | 0 | ||||||
| 132 | } | - | ||||||
| 133 | - | |||||||
| 134 | default never executed: :default:never executed: break;default:never executed: break; | 0 | ||||||
| 135 | } | - | ||||||
| 136 | } | - | ||||||
| 137 | } never executed: end of block | 0 | ||||||
| Switch to Source code | Preprocessed file |