QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCArchiveFile Class Reference

#include <QGCArchiveFile.h>

+ Inheritance diagram for QGCArchiveFile:
+ Collaboration diagram for QGCArchiveFile:

Public Member Functions

 QGCArchiveFile (const QString &archivePath, const QString &entryName, QObject *parent=nullptr)
 
 QGCArchiveFile (QIODevice *source, const QString &entryName, QObject *parent=nullptr)
 
 ~QGCArchiveFile () override=default
 
bool open (OpenMode mode) override
 
qint64 size () const override
 
QString entryName () const
 
qint64 entrySize () const
 
bool entryFound () const
 
QDateTime entryModified () const
 
- Public Member Functions inherited from QGCArchiveDeviceBase
 ~QGCArchiveDeviceBase () override
 
void close () override
 
bool isSequential () const override
 
qint64 bytesAvailable () const override
 
QString errorString () const
 
QString formatName () const
 
QString filterName () const
 

Protected Member Functions

bool initArchive () override
 
bool prepareForReading () override
 
bool isReadyToRead () const override
 
void resetState () override
 Reset all state (called by close())
 
- Protected Member Functions inherited from QGCArchiveDeviceBase
 QGCArchiveDeviceBase (const QString &filePath, QObject *parent=nullptr)
 
 QGCArchiveDeviceBase (QIODevice *source, QObject *parent=nullptr)
 
qint64 readData (char *data, qint64 maxSize) override
 
qint64 writeData (const char *data, qint64 maxSize) override
 
bool initSourceFromPath ()
 
void configureArchiveFormats (bool allFormats)
 
bool openArchive ()
 
bool fillBuffer ()
 
void captureFormatInfo ()
 Capture format info from the archive after first header read.
 

Additional Inherited Members

- Protected Attributes inherited from QGCArchiveDeviceBase
QString _filePath
 
QIODevice * _sourceDevice = nullptr
 
bool _ownsSource = false
 
std::unique_ptr< QIODevice > _ownedSource
 
struct archive * _archive = nullptr
 
QByteArray _resourceData
 
bool _eof = false
 
QByteArray _buffer
 
QString _errorString
 
QString _formatName
 
QString _filterName
 

Detailed Description

QIODevice for reading a single entry from an archive without full extraction Supports ZIP, TAR, 7z, and other libarchive-supported formats Read-only, sequential access only

Example usage:

QGCArchiveFile file("archive.zip", "config.json");
file.open(QIODevice::ReadOnly);
QJsonDocument doc = QJsonDocument::fromJson(file.readAll());

Definition at line 23 of file QGCArchiveFile.h.

Constructor & Destructor Documentation

◆ QGCArchiveFile() [1/2]

QGCArchiveFile::QGCArchiveFile ( const QString &  archivePath,
const QString &  entryName,
QObject *  parent = nullptr 
)

Construct from archive file path

Parameters
archivePathPath to archive file (or Qt resource path :/)
entryNameName of entry to read within the archive
parentQObject parent

Definition at line 13 of file QGCArchiveFile.cc.

◆ QGCArchiveFile() [2/2]

QGCArchiveFile::QGCArchiveFile ( QIODevice *  source,
const QString &  entryName,
QObject *  parent = nullptr 
)

Construct from QIODevice source (streaming)

Parameters
sourceArchive data source (must be open and readable)
entryNameName of entry to read within the archive
parentQObject parent
Note
The source device must remain valid until this device is closed

Definition at line 19 of file QGCArchiveFile.cc.

◆ ~QGCArchiveFile()

QGCArchiveFile::~QGCArchiveFile ( )
overridedefault

Member Function Documentation

◆ entryFound()

bool QGCArchiveFile::entryFound ( ) const
inline

Check if entry was found in archive (available after open)

Returns
true if entry exists and was found

Definition at line 57 of file QGCArchiveFile.h.

◆ entryModified()

QDateTime QGCArchiveFile::entryModified ( ) const
inline

Get entry modification time (available after open)

Returns
Modification time, or invalid QDateTime if unknown

Definition at line 61 of file QGCArchiveFile.h.

◆ entryName()

QString QGCArchiveFile::entryName ( ) const
inline

Get entry name being read

Returns
Entry name within the archive

Definition at line 49 of file QGCArchiveFile.h.

◆ entrySize()

qint64 QGCArchiveFile::entrySize ( ) const
inline

Get entry size (available after open)

Returns
Entry size in bytes, or -1 if unknown

Definition at line 53 of file QGCArchiveFile.h.

◆ initArchive()

bool QGCArchiveFile::initArchive ( )
overrideprotectedvirtual

Initialize libarchive reader with configured format support Subclasses must override to configure format support before calling base

Returns
true on success, sets _errorString on failure

Implements QGCArchiveDeviceBase.

Definition at line 68 of file QGCArchiveFile.cc.

References QGCArchiveDeviceBase::_archive, QGCArchiveDeviceBase::_errorString, QGCArchiveDeviceBase::configureArchiveFormats(), and QGCArchiveDeviceBase::openArchive().

Referenced by open().

◆ isReadyToRead()

bool QGCArchiveFile::isReadyToRead ( ) const
inlineoverrideprotectedvirtual

Check if ready to read data

Returns
true if archive is initialized and ready

Implements QGCArchiveDeviceBase.

Definition at line 66 of file QGCArchiveFile.h.

◆ open()

bool QGCArchiveFile::open ( OpenMode  mode)
override

◆ prepareForReading()

bool QGCArchiveFile::prepareForReading ( )
overrideprotectedvirtual

Called after archive is initialized, before reading begins Subclasses override to seek to entry, read headers, etc.

Returns
true on success, sets _errorString on failure

Implements QGCArchiveDeviceBase.

Definition at line 82 of file QGCArchiveFile.cc.

Referenced by open().

◆ resetState()

void QGCArchiveFile::resetState ( )
overrideprotectedvirtual

Reset all state (called by close())

Reimplemented from QGCArchiveDeviceBase.

Definition at line 87 of file QGCArchiveFile.cc.

References QGCArchiveDeviceBase::resetState().

◆ size()

qint64 QGCArchiveFile::size ( ) const
override

Definition at line 59 of file QGCArchiveFile.cc.


The documentation for this class was generated from the following files: