# List the archives supported by the current script.
# The following format is used for each line, separated by line breaks:
# MD5 hash | archive name
# Some archives might not have an exected MD5 hash, they use the following format instead:
#  | archive name
# (including the leading space, for easier parsing)
# USAGE: archives_list_supported
archives_list_supported() {
	local archive archive_name archive_hashes_list archive_hash
	for archive in $(archives_list_identifiers); do
		archive_name=$(archive_name "$archive")
		archive_hashes_list=$(archive_hashes_list_md5 "$archive")
		if [ -n "$archive_hashes_list" ]; then
			for archive_hash in $archive_hashes_list; do
				printf '%s | %s\n' "$archive_hash" "$archive_name"
			done
		else
			printf ' | %s\n' "$archive_name"
		fi
	done | sort --unique
}

# List all archives supported by the available scripts.
# USAGE: archives_list_supported_all
archives_list_supported_all() {
	local scripts_list
	scripts_list=$(games_list_scripts_all)

	local available_threads
	available_threads=$(nproc)
	## Passing the --list-archives switch is not required,
	## because $PLAYIT_OPTION_LIST_ARCHIVES is already set.
	unset PLAYIT_COMPATIBILITY_LEVEL
	unset target_version
	printf '%s' "$scripts_list" |
		xargs --delimiter='\n' --max-args=1 --max-procs="$available_threads" sh |
		sort --unique
}

