obliteration/gui/pkg_extractor.cpp

36 lines
821 B
C++
Raw Normal View History

2024-03-30 15:27:55 +00:00
#include "pkg_extractor.hpp"
PkgExtractor::PkgExtractor(Rust<Pkg> &&pkg, std::string &&dst) :
2024-03-30 15:27:55 +00:00
m_pkg(std::move(pkg)),
m_dst(std::move(dst))
{
}
PkgExtractor::~PkgExtractor()
{
}
void PkgExtractor::exec()
{
Rust<RustError> e;
e = pkg_extract(
2024-03-30 15:27:55 +00:00
m_pkg,
m_dst.c_str(),
[](const char *status, std::size_t bar, std::uint64_t current, std::uint64_t total, void *ud) {
reinterpret_cast<PkgExtractor *>(ud)->update(status, bar, current, total);
},
this);
if (e) {
emit finished(error_message(e));
2024-03-30 15:27:55 +00:00
} else {
emit finished(QString());
}
}
void PkgExtractor::update(const char *status, std::size_t bar, std::uint64_t current, std::uint64_t total)
{
emit statusChanged(status ? QString(status) : QString(), bar, current, total);
}