| Top |
| char * | g_mime_types_get_mime_type () |
| gboolean | g_mime_types_try_get_extension () |
| void | g_mime_types_register () |
Maps file extensions to MIME-types and MIME-types to preferred extensions, using MimeKit's built-in mappings rather than the host's MIME database. The two directions are independent: a type can have several extensions, and a preferred extension can be shared by aliases of a type.
Registrations are process-wide and survive g_mime_shutdown(). Lookups
and registrations are synchronized, and returned strings are owned copies
that remain valid after later registrations. Comparisons use ASCII
case-insensitivity, as elsewhere in GMime's MIME-type handling.
char *
g_mime_types_get_mime_type (const char *file_name);
Gets the MIME-type based on the last extension of file_name
, without
accessing the file or inspecting its content. Directory separators follow
the host platform. Empty names, extensionless names, trailing dots, and
unknown extensions use application/octet-stream.
gboolean g_mime_types_try_get_extension (const char *mime_type,char **extension);
Looks up the exact MIME-type, ignoring ASCII case. Does not parse or normalize a Content-Type value. An empty or unknown MIME-type is not found.
mime_type |
a MIME-type, without parameters or surrounding whitespace |
|
extension |
the preferred extension,
including its leading dot, or |
[out][transfer full][nullable] |
void g_mime_types_register (const char *mime_type,const char *extension);
Registers both directions of a mapping, replacing any existing entry for this extension and any preferred extension for this MIME-type. Other mappings, including old aliases, remain unchanged. A leading dot is prepended if absent. Values are copied as supplied, without trimming, validation of MIME syntax, or case normalization.
The two updates are atomic with respect to other registry operations.