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

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Wed May 9 17:04:18 CEST 2012



On Wed, 9 May 2012, Graeme Geldenhuys wrote:

> 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"

Correct.

>
> 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
> really?
>

Based on my personal experience: very.
I've had this file in use since 18 years at least, since the first NCSA
webserver installations.

> 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.

A webserver does not do that. It uses the mime file.

the 'file' command looks at the magic numbers, but for example KDE looks at
the extension.

Michael.




More information about the Lazarus mailing list