1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:48:13 +00:00

file: Use the mime-type description provided by LibCore

This allows us to get rid of another mime-type list in the codebase.

To do so, the `get_description_from_mime_type` function is introduced in
this patch.
This commit is contained in:
Lucas CHOLLET 2023-07-11 19:03:23 -04:00 committed by Sam Atkins
parent c543a13835
commit 15bd708cfd
3 changed files with 35 additions and 57 deletions

View file

@ -166,6 +166,16 @@ Optional<StringView> guess_mime_type_based_on_sniffed_bytes(ReadonlyBytes bytes)
return {};
}
Optional<StringView> get_description_from_mime_type(StringView mime_name)
{
for (auto const& mime_type : s_registered_mime_type) {
if (mime_name == mime_type.name)
return mime_type.description;
}
return OptionalNone {};
}
Optional<StringView> guess_mime_type_based_on_sniffed_bytes(Core::File& file)
{
// Read accounts for longest possible offset + signature we currently match against (extra/iso-9660)