Resource Class

class QInstaller::Resource

The Resource class is an interface for wrapping a file as read only device. More...

Header: #include <Resource>
Inherits: QIODevice

Public Functions

Resource(const QString &path, const Range<qint64> &segment)
Resource(const QString &path, const QByteArray &name)
Resource(const QString &path)
virtual ~Resource()
void copyData(QFileDevice *out)
QByteArray name() const
bool open()
Range<qint64> segment() const
void setName(const QByteArray &name)
void setSegment(const Range<qint64> &segment)

Reimplemented Public Functions

virtual void close() override
virtual bool seek(qint64 pos) override
virtual qint64 size() const override

Static Public Members

void copyData(QInstaller::Resource *resource, QFileDevice *out)

Detailed Description

Resource is an interface for reading inside a file, but is not supposed to write to the file it wraps. The Resource class is created by passing a path to an existing binary (such as a zipped archive or a Qt resource file).

The resource name can be set at any time using setName() or during construction. The segment supplied during construction represents the offset and size of the resource inside the file.

Member Function Documentation

Resource::Resource(const QString &path, const Range<qint64> &segment)

Creates a resource providing the data in path limited to segment.

Resource::Resource(const QString &path, const QByteArray &name)

Creates a resource providing the data in path identified by name.

Resource::Resource(const QString &path)

Creates a resource providing the data in path.

[virtual] Resource::~Resource()

Destroys the resource. Calls close() if necessary before destroying the resource.

[override virtual] void Resource::close()

Reimplements: QIODevice::close().

void Resource::copyData(QFileDevice *out)

Copies the resource data to a file called out. Throws Error on failure.

[static] void Resource::copyData(QInstaller::Resource *resource, QFileDevice *out)

This is an overloaded function.

Copies the resource data of resource to a file called out. Throws Error on failure.

QByteArray Resource::name() const

Returns the name of the resource.

See also setName().

bool Resource::open()

Opens a resource in QIODevice::ReadOnly mode. The function returns true if successful.

[override virtual] bool Resource::seek(qint64 pos)

Reimplements: QIODevice::seek(qint64 pos).

Range<qint64> Resource::segment() const

Returns the range inside the file this resource represents.

See also setSegment().

void Resource::setName(const QByteArray &name)

Sets the name of the resource to name.

See also name().

void Resource::setSegment(const Range<qint64> &segment)

Sets the range to the segment of the file that this resource represents.

See also segment().

[override virtual] qint64 Resource::size() const

Reimplements: QIODevice::size() const.

© 2018 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. The Qt Company, Qt and their respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.