/*
 * 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/.
 */

#pragma once

#include "ArchiveType.hpp"
#include <string>

namespace OpenVulkano
{
	enum class CompressionType { AUTO = 0, NONE, GZIP, BZIP2, XZ, LZ4, ZSTD };

	struct ArchiveConfiguration final
	{
		ArchiveType type;
		CompressionType compression;
		int compressionLevel;

		constexpr ArchiveConfiguration(ArchiveType archiveType = ArchiveType::TAR,
									   CompressionType compressionType = CompressionType::AUTO,
									   int level = -1)
									   : type(archiveType), compression(compressionType), compressionLevel(level)
		{}

		[[nodiscard]] static ArchiveConfiguration FromFileName(const char* fileName);

		[[nodiscard]] std::string GetFileExtension() const;

		[[nodiscard]] int GetLibArchiveArchiveType() const;

		[[nodiscard]] int GetLibArchiveCompressionType() const;
	};

	namespace ArchiveConfig
	{
		inline constexpr ArchiveConfiguration TAR     = {ArchiveType::TAR, CompressionType::NONE, 0};
		inline constexpr ArchiveConfiguration TAR_GZ  = {ArchiveType::TAR, CompressionType::GZIP, 6};
		inline constexpr ArchiveConfiguration TAR_GZ1  = {ArchiveType::TAR, CompressionType::GZIP, 1};
		inline constexpr ArchiveConfiguration TAR_GZ9 = {ArchiveType::TAR, CompressionType::GZIP, 9};
		inline constexpr ArchiveConfiguration TAR_LZ4 = { ArchiveType::TAR, CompressionType::LZ4, 4};
		inline constexpr ArchiveConfiguration TAR_ZSTD = { ArchiveType::TAR, CompressionType::ZSTD, 3};
	}
}
