mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
MIME: add lookup function for file name extension for MIME type
This commit is contained in:
parent
a1a394ce4b
commit
a3e5a9b222
@ -2636,6 +2636,13 @@ guess_mime_type_by_ext(std::string ext) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string
|
||||
primary_file_extension_for_mime_type(std::string const &mime_type) {
|
||||
auto itr = brng::find_if(mime_types, [&mime_type](auto const &m) { return m.name == mime_type; });
|
||||
|
||||
return (itr != mime_types.end()) && !itr->extensions.empty() ? itr->extensions[0] : std::string{};
|
||||
}
|
||||
|
||||
#if HAVE_MAGIC_H
|
||||
static std::string
|
||||
guess_mime_type_by_content(magic_t &m,
|
||||
|
@ -37,6 +37,7 @@ extern std::vector<std::string> const g_popular_country_codes;
|
||||
extern std::vector<mime_type_t> const mime_types;
|
||||
|
||||
std::string guess_mime_type(std::string ext, bool is_file);
|
||||
std::string primary_file_extension_for_mime_type(std::string const &mime_type);
|
||||
boost::optional<std::string> map_to_cctld(std::string const &s);
|
||||
|
||||
#endif // MTX_COMMON_EXTERN_DATA_H
|
||||
|
Loading…
Reference in New Issue
Block a user