From fe97303ee7bf61db6e24880acb805a88c633d9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Vogtl=C3=A4nder?= Date: Wed, 12 Nov 2014 17:57:35 +0100 Subject: Fix binary data extraction Extract binary data based on list of available package names when using "devtool --dump" or "--create-offline-repository" installer option. An entry in meta data resource only exists if the component actually has meta data (e.g. a script) so it is not possible to rely on sub directory structure after copying meta data to extract binary data. Change-Id: Icd70d3495a921229f0043360b93905dc36cf6514 Task-number: QTIFW-574 Reviewed-by: Karsten Heimrich --- tools/devtool/binarydump.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tools/devtool') diff --git a/tools/devtool/binarydump.cpp b/tools/devtool/binarydump.cpp index 0952c92a4..046d41d25 100644 --- a/tools/devtool/binarydump.cpp +++ b/tools/devtool/binarydump.cpp @@ -108,22 +108,22 @@ int BinaryDump::dump(const QInstaller::ResourceCollectionManager &manager, const } } - QDirIterator it(targetDir, QDirIterator::Subdirectories); - while (it.hasNext() && !it.next().isEmpty()) { - if (!it.fileInfo().isDir()) - continue; - - const QString fileName = it.fileName(); - const QInstaller::ResourceCollection c = manager.collectionByName(fileName.toUtf8()); + foreach (const QString &name, versionMap.keys()) { + const QInstaller::ResourceCollection c = manager.collectionByName(name.toUtf8()); if (c.resources().count() <= 0) continue; + if (!targetDir.mkpath(name)) { + throw QInstaller::Error(QString::fromLatin1("Could not create target dir: %1.") + .arg(targetDir.filePath(name))); + } + foreach (const QSharedPointer &resource, c.resources()) { const bool isOpen = resource->isOpen(); if ((!isOpen) && (!resource->open())) continue; // TODO: should we throw here? - QFile target(targetDir.filePath(fileName) + QDir::separator() + QFile target(targetDir.filePath(name) + QDir::separator() + QString::fromUtf8(resource->name())); QInstaller::openForWrite(&target); resource->copyData(&target); // copy the 7z files into the target directory -- cgit v1.2.3