Resource Class
(QInstaller::Resource)The Resource class is an interface for wrapping a file as read only device. More...
Header: | #include <Resource> |
Public Functions
Resource(const QString &path) | |
Resource(const QString &path, const QByteArray &name) | |
Resource(const QString &path, const Range<qint64> &segment) | |
~Resource() | |
void | close() |
void | copyData(QFileDevice *out) |
QByteArray | name() const |
bool | open() |
bool | seek(qint64 pos) |
Range<qint64> | segment() const |
void | setName(const QByteArray &name) |
void | setSegment(const Range<qint64> &segment) |
qint64 | size() const |
Static Public Members
void | copyData(Resource *resource, QFileDevice *out) |
Detailed Description
The Resource class is an interface for wrapping a file as read only device.
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)
Creates a resource providing the data in path.
Resource::Resource(const QString &path, const QByteArray &name)
Creates a resource providing the data in path identified by name.
Resource::Resource(const QString &path, const Range<qint64> &segment)
Creates a resource providing the data in path limited to segment.
Resource::~Resource()
Destroys the resource. Calls close() if necessary before destroying the resource.
void Resource::close()
void Resource::copyData(QFileDevice *out)
Copies the resource data to a file called out. Throws Error on failure.
[static]
void Resource::copyData(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.
bool Resource::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().