move more zip parsings

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2025-07-11 00:43:28 +03:00
parent 8c36be048c
commit f38a0c8f98
20 changed files with 167 additions and 251 deletions

View File

@@ -40,7 +40,6 @@ QByteArray ArchiveReader::File::readAll(int* outStatus)
if (outStatus) {
*outStatus = status;
}
archive_read_close(m_archive.get());
return data;
}
@@ -131,7 +130,7 @@ bool ArchiveReader::File::writeFile(archive* out, QString targetFileName, bool n
return (r > ARCHIVE_WARN);
}
bool ArchiveReader::parse(std::function<bool(File*)> doStuff)
bool ArchiveReader::parse(std::function<bool(File*, bool&)> doStuff)
{
auto f = std::make_unique<File>();
auto a = f->m_archive.get();
@@ -143,16 +142,24 @@ bool ArchiveReader::parse(std::function<bool(File*)> doStuff)
return false;
}
bool breakControl = false;
while (f->readNextHeader() == ARCHIVE_OK) {
if (!doStuff(f.get())) {
if (!doStuff(f.get(), breakControl)) {
qCritical() << "Failed to parse file:" << f->filename() << "-" << f->error();
return false;
}
if (breakControl) {
break;
}
}
archive_read_close(a);
return true;
}
bool ArchiveReader::parse(std::function<bool(File*)> doStuff)
{
return parse([doStuff](File* f, bool&) { return doStuff(f); });
}
bool ArchiveReader::File::isFile()
{