BinaryContent Class | Qt Installer Framework Manual

- Qt Installer Framework Manual
- BinaryContent

# BinaryContent Class

class QInstaller::BinaryContent

The BinaryContent class handles binary information embedded into executables. More...

Header: | #include <BinaryContent>

- List of all members, including inherited members

## Static Public Members

QInstaller::BinaryLayout | binaryLayout(QFile *file, quint64 magicCookie)
qint64 | findMagicCookie(QFile *in, quint64 magicCookie)
void | readBinaryContent(QFile *file, QList<QInstaller::OperationBlob> *operations, QInstaller::ResourceCollectionManager *manager, qint64 *magicMarker, quint64 magicCookie)
void | writeBinaryContent(QFile *out, const QList<QInstaller::OperationBlob> &operations, const QInstaller::ResourceCollectionManager &manager, qint64 magicMarker, quint64 magicCookie)

## Detailed Description

The following types of binary information can be embedded into executable files: Qt resources, performed operations, and resource collections.

The magic marker is a `quint64` that identifies the kind of the binary: `installer` or `uninstaller` (maintenance tool).

The magic cookie is a `quint64` describing whether the binary is the file holding just data or whether it includes the executable as well.

## Member Function Documentation

### `[static]` QInstaller::BinaryLayout BinaryContent::binaryLayout(QFile *file, quint64 magicCookie)

Tries to read the binary layout of the file file. It starts searching from the end of the file file for the given magicCookie using findMagicCookie(). If the cookie was found, it fills a BinaryLayout structure and returns it. Throws Error on failure.

### `[static]` qint64 BinaryContent::findMagicCookie(QFile *in, quint64 magicCookie)

Searches for the given magic cookie magicCookie starting from the end of the file in. Returns the position of the magic cookie inside the binary. Throws Error on failure.

Note: Searches through up to 1MB of data, if smaller, through the whole file.

### `[static]` void BinaryContent::readBinaryContent(QFile *file, QList<QInstaller::OperationBlob> *operations, QInstaller::ResourceCollectionManager *manager, qint64 *magicMarker, quint64 magicCookie)

Reads the binary content of the given file file. It starts by reading the binary layout of the file using binaryLayout() using magicCookie. Throws Error on failure.

If operations is not 0, it is set to the performed operations from a previous run of for example the maintenance tool.

If manager is not 0, it is first cleared and then set to the resource collections embedded into the binary.

If magicMarker is not 0, it is set to the magic marker found in the binary.

### `[static]` void BinaryContent::writeBinaryContent(QFile *out, const QList<QInstaller::OperationBlob> &operations, const QInstaller::ResourceCollectionManager &manager, qint64 magicMarker, quint64 magicCookie)

Writes the binary content to the given file out. Throws Error on failure.

The binary content is written in the following order:

- Meta resources manager
- Operations operations
- Resource collections manager
- Magic marker magicMarker
- Magic cookie magicCookie

For more information see the BinaryLayout documentation.