On 03/07/11 00:24, Jonathan M Davis wrote: > On Sunday 06 March 2011 22:09:22 Nick Sabalausky wrote: >> "Jonathan M Davis" <[email protected]> wrote in message >> news:[email protected]... >> >>> This reminds me. I should look into mime types one of these days to see >>> what the >>> appropriate way (if any) would be to put support for them in Phobos. It >>> would be >>> nice to not have to go by extension for the few programs that I have >>> which have >>> to worry about file type. >> >> I'm no unix expert, but my understanding is that mime types in the >> filesystem don't even exist at all, and that what it *really* does is use >> some complex black-box-ish algorithm that takes into account the first few >> bytes of the file, the extention, the exec flag, and god-knows-what-else to >> determine what type of file it is. Contrary to how people keep making it >> sound, mime type is *not* the determining factor (and cannot possibly be), >> but rather nothing more than the way the *result* of all that analysis is >> represented. > > I thought that the first few bytes of the file _were_ the mime type. > Certainly, > from what I've seen, extension has _no_ effect on most programs. Konqueror > certainly acts like it does everything by mime type - file associations are > set > that way. > > - Jonathan M Davis
As someone who uses hex editors quite a bit (resorting these days to using Okteta mainly), I can tell you I have yet to see any file's mime embedded at the beginning, nor have I seen it in any headers/nodes when scanning raw. Doesn't mean it's impossible of course, and certain file systems certainly might do this[1] but I haven't seen it yet[2]. You are quite right, though, that extension doesn't matter at all, except in certain corner cases. Even then, they are reasonable and predictable things -- like SO's having the right extension. Considering the posix convention of "hiding" files/directories by starting the name with a dot, it'd be hard to rely on extensions in any naive way anyhow. ;) -- Chris N-S [1] I'd just about expect the filesystem of BeOS/Haiku to do so, or something similar to it at least. [2] Also not saying I wouldn't want to see it, necessarily. Done right, it'd be a damn nifty thing.
