A file listing which magic bytes within a file indicate the likely file type Those magic bytes are then mapped to a mime type. the file command uses a similar (the same?) database.
I suppose it isn't all that different to just check the magic whenever the user opens a file but I have had at least one occasion where I wanted to change the mime type of a particular file that Nautilus (the Gnome file manager) didn't guess right. With BeOS's scheme, the magic check is only done when there isn't a mime type attribute already associated with the file. Once that attribute is created you can tweak it if you wish. And I was mistaken. BeOS checks the extension first, then the magic byte signature.
According to the Nautilus user manual (I don't have a working Gnome here to verify), you can assign primary and secondary actions to either a general mime type or to a particular file. I don't know why I missed this in my case. The UI for such things in Gnome is rather bad at the moment.
OT PS: The is the wrong mime magic: [link|http://www.annamime.com/wow.html|http://www.annamime.com/wow.html]