diff options
author | kh1 <karsten.heimrich@digia.com> | 2014-10-14 17:03:54 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2014-10-15 17:10:18 +0200 |
commit | 84875396b75f5615afa637f9633d19bbc79e08e0 (patch) | |
tree | 012fe931425ae267361a608c0c63e0d05e4ee03e /src/libs/installer/createlocalrepositoryoperation.cpp | |
parent | ec92e19193eb9d69a3cf18979d6434cf04764902 (diff) |
Overhaul the binary format API.
Adjust some naming. Add documentation. Make the Resource class
handle files only, this is sufficient to read and map inbuild
resources. Keep the QResources inside the manager as well, no
need to handle them separate. Remove read, write functions from
collection class, the API was just unclear how to use. Still it
is far from intuitive in the manager class either. If we open a
Resource, we need to close it on our own case they are pointers.
Change-Id: Ic8aa32a84a15ac774fe1194ba0dbb5733f7216d6
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/createlocalrepositoryoperation.cpp')
-rw-r--r-- | src/libs/installer/createlocalrepositoryoperation.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp index cfec09585..e550a8997 100644 --- a/src/libs/installer/createlocalrepositoryoperation.cpp +++ b/src/libs/installer/createlocalrepositoryoperation.cpp @@ -250,15 +250,15 @@ bool CreateLocalRepositoryOperation::performOperation() emit progressChanged(0.50); - QSharedPointer<QFile> file(new QFile(binaryPath)); - if (!file->open(QIODevice::ReadOnly)) { - throw QInstaller::Error(tr("Could not open file: %1. Error: %2").arg(file->fileName(), - file->errorString())); + QFile file(binaryPath); + if (!file.open(QIODevice::ReadOnly)) { + throw QInstaller::Error(tr("Could not open file: %1. Error: %2").arg(file.fileName(), + file.errorString())); } // start to read the binary layout ResourceCollectionManager manager; - BinaryContent::readBinaryContent(file, 0, 0, &manager, 0, BinaryContent::MagicCookie); + BinaryContent::readBinaryContent(&file, 0, &manager, 0, BinaryContent::MagicCookie); QDirIterator it(repoPath, QDirIterator::Subdirectories); while (it.hasNext() && !it.next().isEmpty()) { @@ -277,7 +277,8 @@ bool CreateLocalRepositoryOperation::performOperation() // copy the 7z files that are inside the component index into the target const ResourceCollection collection = manager.collectionByName(fileName.toUtf8()); foreach (const QSharedPointer<Resource> &resource, collection.resources()) { - if (!resource->open()) + const bool isOpen = resource->isOpen(); + if ((!isOpen) && (!resource->open())) continue; QFile target(absoluteTargetPath + QDir::separator() @@ -286,6 +287,9 @@ bool CreateLocalRepositoryOperation::performOperation() resource->copyData(&target); helper.m_files.prepend(target.fileName()); emit outputTextChanged(helper.m_files.first()); + + 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. } } } |