Nick Sabalausky wrote: > "Jonathan M Davis" <[email protected]> wrote in message > news:[email protected]... >> On Wednesday, September 15, 2010 12:48:32 Nick Sabalausky wrote: >>> "Jonathan M Davis" <[email protected]> wrote in message >>> news:[email protected]... >>> >>> > If you're on a non-Windows system, the mime-type becomes far more >>> > important than >>> > the extension. Most programs in Linux (and I believe MacOS X as well) >>> > don't care >>> > about the extension. They just look at the mime type. Extensions become >>> > almost >>> > entirely a thing for the user. So, whether your file is useable becomes >>> > more of >>> > an issue of known mime type than known extension. Still, you don't >>> > generally >>> > want to just be making up extensions. >>> >>> I didn't think unix file systems had a concept of mime type. >> >> They don't have a concept of file extension either. Mime types has to do >> with the >> contents of the file and file extensions has to do with the name of the >> file. It's >> programs which interpret those, not the file system. Typically, on >> Windows, the >> extension is used by the OS to determine which program to use to open a >> file. In >> unix, it's the mime type that's used to determine that. >> >> The one bit of overlap there is the fact that Windows treats the exe >> extension >> essentially the way that unix treats the executable file attribute. >> >> Now, I wouldn't advise ditching file extensions in unix, since it not only >> can >> help the human using them but there are occasionally programs which check >> the >> extension rather the mime type (so, ultimately, you may end up using both >> the >> extension and the mime type), but it's primarily the mime type which is >> used, >> and it's definitely the mime type which is used to determine which program >> to use >> to open a file in the desktop environments. >> > > Yea, but my question was more "how in the hell would it know the mime type > of a file in the first place?" It's obviously not stored in the filename, > and 99.9% is the time it's not stored in the file's data either. > > Since then, someone mentioned it typically analyses the content of the file > and infers the mime type based on that. That's news to me. It would seem > limited and error-prone though, so I have a hard time believing it doesn't > suppliment that content-analysis with extension-checking in many cases.
Such a combination is sometimes used. Dolphin for example gives precedence to some extensions. But you'd be surprised how good content analysis alone works, for 99% of files I open from the desktop there is no extension required - it just works. Mostly you have either plain text or a well defined binary format.
