archive::archive(const std::string& fileName) : archiveLibarchive(fileName) { applyFormats(); int ret = archive_read_open_filename(m_archive, fileName.c_str(), 4096); if (ret != ARCHIVE_OK) { archive_read_free(m_archive); m_archive = nullptr; throw std::runtime_error("libstriezel::ar::archive: Failed to open file " + fileName + "!"); } //fill entries fillEntries(); }
void archiveLibarchive::reopen() { //close and re-open archive to get to the first entry again archive_read_free(m_archive); m_archive = nullptr; m_archive = archive_read_new(); if (nullptr == m_archive) throw std::runtime_error("libstriezel::archive::archiveLibarchive::reopen(): Could not allocate archive structure!"); applyFormats(); int r2 = archive_read_open_filename(m_archive, m_fileName.c_str(), 4096); if (r2 != ARCHIVE_OK) { archive_read_free(m_archive); m_archive = nullptr; throw std::runtime_error("libstriezel::archive::archiveLibarchive::reopen(): Failed to re-open file " + m_fileName + "!"); } }