/*
 * 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 "SimpleFileTypeShouldCompressChecker.hpp"
#include "Base/Utils.hpp"
#include <set>

namespace OpenVulkano
{
	namespace
	{
		const std::set<std::string_view> INCOMPRESSIBLE_TYPES = {
				// Image formats
				"jpg", "jpeg", "png",
				// Video formats
				"mp4",
				// Audio formats
				"mp3", "aac", "ac3",
				// Other
		};
	}

	bool SimpleFileTypeShouldCompressChecker(const FileDescription& fileDescription)
	{
		auto [fName, fType] = Utils::SplitAtLastOccurrence(fileDescription.path, '.');
		std::transform(fType.begin(), fType.end(), fType.begin(), ::tolower); // fType to lowercase
		return !INCOMPRESSIBLE_TYPES.count(fType);
	}
}