GNOME Bugzilla – Bug 513413
provide option to force mime-type sniffing
Last modified: 2008-02-01 11:03:46 UTC
In gnome-vfs there was the GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE option to the GnomeVFSFileInfo interface which forced the use of mime-type sniffing. GIO doesn't have an equivalent and can be mislead by the filename. Example (using G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE): 1. Take a jpeg file and determine its mime type. Should something like "image/jpeg" 2. Rename the file to image.png 3. Check the mime type of that file. It is "image/png". This can lead to problems if you need to take different actions depending on the mime type.
Forcing sniffing of mime types have other kinds of problems, like being extremely slow. And failure in this case is much harder to fix for the user. (you'd have to report the error to freedesktop.org and wait for a new shared-mime-data release, assuming the magic rules can even be fixed). This has been discussed on the xdg list and we have decided to change the mime spec recommended ordering of sniffing vs globs. I don't think its a good idea to expose the slow mime type in an easy to get way as its not something most apps should use. However, if you really want to do the sniffing, you can just use g_content_type_guess().