[Lazarus] Function to get the mimetype from a file extension

Graeme Geldenhuys graemeg.lists at gmail.com
Wed May 9 16:47:56 CEST 2012

On 9 May 2012 14:51,  <michael.vancanneyt at wisa.be> wrote:
> It is used by fcl-web. On linux, it loads /etc/mime.types.

I don't know the exact format of that file, I guessed "mime type name"
then "file extension list"

But on my Ubuntu 10.04 that file has many lines only showing the "mime
type name" with no extension mentioned. So how reliable is that file

I know Linux (at least Gnome) uses magic numbers (first 2-4 bytes of a
file) to detect the real file type without looking at the file
extension. These magic numbers information is stored somewhere in
linux (can't remember where now), and it includes the magic number and
mime type mapping. I'll see if I can find the file I am talking about.
But as with everything Linux, this is probably highly distro specific

  - Graeme -

fpGUI - a cross-platform Free Pascal GUI toolkit

More information about the Lazarus mailing list