5#include <archive_entry.h>
15 , _entryName(entryName)
21 , _entryName(entryName)
31 if (mode != ReadOnly) {
32 _errorString = QStringLiteral(
"QGCArchiveFile only supports ReadOnly mode");
36 if (_entryName.isEmpty()) {
37 _errorString = QStringLiteral(
"Entry name cannot be empty");
56 return QIODevice::open(mode);
61 return _entrySize >= 0 ? _entrySize : QIODevice::size();
72 _errorString = QStringLiteral(
"Failed to create archive reader");
92 _entryModified = QDateTime();
99bool QGCArchiveFile::seekToEntry()
101 struct archive_entry *entry =
nullptr;
104 while (archive_read_next_header(
_archive, &entry) == ARCHIVE_OK) {
110 const QString currentEntry = QString::fromUtf8(archive_entry_pathname(entry));
112 if (currentEntry == _entryName) {
114 _entrySize = archive_entry_size(entry);
117 if (archive_entry_mtime_is_set(entry)) {
118 _entryModified = QDateTime::fromSecsSinceEpoch(archive_entry_mtime(entry));
121 qCDebug(QGCArchiveFileLog) <<
"Found entry:" << _entryName
122 <<
"size:" << _entrySize
123 <<
"modified:" << _entryModified;
131 _errorString = QStringLiteral(
"Entry not found in archive: ") + _entryName;
QIODevice for reading a single entry from an archive.
#define QGC_LOGGING_CATEGORY(name, categoryStr)
void captureFormatInfo()
Capture format info from the archive after first header read.
struct archive * _archive
void configureArchiveFormats(bool allFormats)
virtual void resetState()
Reset all state (called by close())
bool initSourceFromPath()
QGCArchiveFile(const QString &archivePath, const QString &entryName, QObject *parent=nullptr)
bool open(OpenMode mode) override
void resetState() override
Reset all state (called by close())
qint64 size() const override
bool prepareForReading() override
bool initArchive() override