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

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Wed May 9 15:59:35 CEST 2012

On Wed, May 9, 2012 at 2:46 PM, waldo kitty <wkitty42 at windstream.net> wrote:
> wouldn't it be better to use mimemagic instead of relying on the file's
> extension?

You mean opening the file and reading the first bytes? For my use case
that's an over complication, and subject to multiple possible errors:
Permission errors for example. Not really nice.

I am implementing LCLIntf.OpenDocument and LCLIntf.OpenURL for
Android, and here it might be good to just let whatever app that is
choosen handle the file and never open it myself.

> i can easily name foo.gif as foo.txt and those systems that do properly look

Though luck of whoever changed the extension. That makes choosing the
file in dialogs also problematic. I don't care about this use case.

Felipe Monteiro de Carvalho

More information about the Lazarus mailing list