Questions regarding the shared mime spec

David Faure faure at kde.org
Sun Oct 2 01:08:54 PDT 2011


On Saturday 01 October 2011 17:08:43 Johannes Pfau wrote:
> When checking multiple mime.cache files: Should I check those one after
> one or should I first do glob matches in all databases, then magic
> matches in all data bases, etc?

The definitions in later levels override those in earlier levels. This makes 
it possible for a user to remove a glob from a mimetype, for instance.
I'm not sure how this is modelled in mime.cache, but at least with the 
generated text files, the idea is to view all this as a "merge" where local 
overrides global.
But yes, since glob comes before magic, you should do glob matching first 
(looking at the merged view of all levels), and then magic (again looking at 
the merged view of all levels).

> And one last (off-topic) question: Windows and OSX don't have similar
> apis/databases, right? Windows seems to have a simple
> extension-->mimetype mapping in the registry, but mac doesn't have a
> public mime type api at all?

Right, my similar question on the qt5-feedback list confirmed this.
What I got about the Mac is:
> as for mac, names for file types are not even mime names - for
> example "mkv" is something like "movie", not "video/x-matroska". 
And Windows only looks at extensions, not content.

I'm more and more inclined to just use shared-mime-info on all platforms,
so that apps can use the same code when checking "is file foo of mimetype 
bar". Unfortunately associating apps with mimetypes is a more complex issue, 
if e.g. Windows and shared-mime-info don't call it the same way...

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).


More information about the xdg mailing list