[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Determine mime type of a file
- From: Marco <netuse@...>
- Date: Mon, 2 May 2011 12:23:25 +0200
On 2011-05-02 steve donovan <email@example.com> wrote:
> On Mon, May 2, 2011 at 11:32 AM, Marco <firstname.lastname@example.org> wrote:
> > What do you mean by catalog? A file extension - mime
> > type mapping?
> That is exactly what the Gnome MIME XML files provide.
Thanks for the pointer, I'll have a look at it.
> > That would quickly break when a file has no extension
> > (file -i is not confused by this).
> Well, if we can't find it,
Can't find what? The “file” executable, the extension, the
mime type? Anyway…
> then we have to give some default, like text/plain or
That makes no sense in my case, since all files are binary
and I have to test for a particular type.
> A portable solution would start with a list of the
> common registered MIME types, and encode it as a Lua
Apparently there doesn't seem to be a “file” like
implementation in lua. I'll precede as follows:
1) Check if “file” binary is available, if not
2) check if file has extension, if yes, compare to a
mapping list, if not
3) assume (possibly valid) file as invalid.
Thanks, for the quick answers