diff options
Diffstat (limited to 'tools/devtool')
-rw-r--r-- | tools/devtool/binarydump.cpp | 6 | ||||
-rw-r--r-- | tools/devtool/main.cpp | 17 |
2 files changed, 15 insertions, 8 deletions
diff --git a/tools/devtool/binarydump.cpp b/tools/devtool/binarydump.cpp index 8c73d7642..7efa13960 100644 --- a/tools/devtool/binarydump.cpp +++ b/tools/devtool/binarydump.cpp @@ -126,13 +126,17 @@ int BinaryDump::dump(const QInstaller::ResourceCollectionManager &manager, const continue; foreach (const QSharedPointer<QInstaller::Resource> &resource, c.resources()) { - if (!resource->open()) + const bool isOpen = resource->isOpen(); + if ((!isOpen) && (!resource->open())) continue; // TODO: should we throw here? QFile target(targetDir.filePath(fileName) + QDir::separator() + QString::fromUtf8(resource->name())); QInstaller::openForWrite(&target); resource->copyData(&target); // copy the 7z files into the target directory + + if (!isOpen) // If we reach that point, either the resource was opened already... + resource->close(); // or we did open it and have to close it again. } } result = EXIT_SUCCESS; diff --git a/tools/devtool/main.cpp b/tools/devtool/main.cpp index 9ef611ce2..61be6c9f7 100644 --- a/tools/devtool/main.cpp +++ b/tools/devtool/main.cpp @@ -136,24 +136,27 @@ int main(int argc, char *argv[]) } } - QSharedPointer<QFile> file(new QFile(path)); - QInstaller::openForRead(file.data()); + QFile file(path); + QInstaller::openForRead(&file); qint64 magicMarker; - QInstaller::ResourceCollection meta; QList<QInstaller::OperationBlob> operations; QInstaller::ResourceCollectionManager manager; - QInstaller::BinaryContent::readBinaryContent(file, &meta, &operations, &manager, - &magicMarker, cookie); + QInstaller::BinaryContent::readBinaryContent(&file, &operations, &manager, &magicMarker, + cookie); // map the inbuilt resources + const QInstaller::ResourceCollection meta = manager.collectionByName("QResources"); foreach (const QSharedPointer<QInstaller::Resource> &resource, meta.resources()) { - const bool opened = resource->open(); + const bool isOpen = resource->isOpen(); + if ((!isOpen) && (!resource->open())) + continue; // TODO: should we throw here? + const QByteArray ba = resource->readAll(); if (!QResource::registerResource((const uchar*) ba.data(), QLatin1String(":/metadata"))) throw QInstaller::Error(QLatin1String("Could not register in-binary resource.")); resourceMappings.append(ba); - if (opened) + if (!isOpen) resource->close(); } |