Update genericModel.cc

This commit is contained in:
__Rylex__
2024-01-16 23:50:58 -08:00
committed by GitHub
parent c7b380bece
commit dab121e94b

View File

@@ -34,7 +34,7 @@ bool genericModel::loadModel() {
fireEv("error", "Unable to fetch model"); fireEv("error", "Unable to fetch model");
return false; return false;
} }
if(!extractModel("opfs/model.tzst", ".")) { if(!extractModel(".")) {
fireEv("error", "Unable to extract model"); fireEv("error", "Unable to extract model");
} }
fs::remove("opfs/model.tzst"); fs::remove("opfs/model.tzst");
@@ -51,17 +51,17 @@ bool genericModel::loadModel() {
} }
return true; return true;
} }
bool genericModel::extractModel(const char* target, const std::string& dest) { bool genericModel::extractModel() {
std::string path{}; std::string path{};
archive* src {archive_read_new()}; archive* src {archive_read_new()};
archive_entry* entry {}; archive_entry* entry {};
archive_read_support_filter_all(src); archive_read_support_filter_all(src);
archive_read_support_format_all(src); archive_read_support_format_all(src);
archive_read_open_filename(src, ".",10240); archive_read_open_filename(src, "opfs/model.tzst",10240);
if(archive_errno(src) != 0) return false; if(archive_errno(src) != 0) return false;
while (archive_read_next_header(src, &entry) == ARCHIVE_OK) { while (archive_read_next_header(src, &entry) == ARCHIVE_OK) {
path = archive_entry_pathname(entry); path = archive_entry_pathname(entry);
archive_entry_set_pathname(entry, (dest + path.substr(path.find("/"))).c_str()); archive_entry_set_pathname(entry, path.substr(path.find("/")).c_str());
if(archive_errno(src) != 0) return false; if(archive_errno(src) != 0) return false;
archive_read_extract(src, entry, ARCHIVE_EXTRACT_UNLINK); archive_read_extract(src, entry, ARCHIVE_EXTRACT_UNLINK);
} }