/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#include "ArchiveBase.hpp"
#include "LibArchiveHelper.hpp"

namespace OpenVulkano
{
	ArchiveBase::ArchiveBase(archive* arch, archive_entry* archEntry, const std::shared_ptr<spdlog::logger>& logger)
		: m_archive(arch), m_archiveEntry(archEntry), m_logger(logger)
	{
		if (!m_logger)
		{
			m_logger = Logger::FILESYS;
		}
	}

	ArchiveBase::~ArchiveBase()
	{
		ChkErr(archive_free(m_archive));
	}

	bool ArchiveBase::ChkErr(long result) const
	{
		return LibArchiveHelper::CheckError(result, m_archive, m_logger);
	}
}