[haiku-development] Re: File command?

  • From: Don Quixote de la Mancha <quixote@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 3 Oct 2011 08:51:38 -0700

On Mon, Oct 3, 2011 at 8:37 AM, Stephan Aßmus <superstippi@xxxxxx> wrote:
> I am not sure what exactly the purpose of file is, but the expectations of a
> CLI user may depend on the exact situation. For example, bypassing the Haiku
> mime detection may actually be the point of using file.

The file command inspects the data in the file, then tries to match it
to a known pattern.  Many well-known file formats start with a "Magic
Number" which is quite often 32 bits.

For example TIFF files have the ASCII either MM or II for a byte order
marker (Big or Little, Motorola or Intel) followed by the ASCII for
TIFF (or maybe the byte order comes after the magic number, I don't
recall).

On Mac OS X the file command can tell if executables and libraries are
Universal, that is, whether they have 32-bit or 64-bit code or both,
as well as containing PowerPC or Intel or both.

A problematic case is OpenOffice.org files, which are Zip archives of
a small directory heirarchy full of XML files.  The problem here is
that the compression messes up the recognizable data bytes.

I would think that many scripts - or users - would want to set the
mimetype based on what the file command reports, rather than the other
way round, that is, having file check BEOS:TYPE.



-- 
Don Quixote de la Mancha
Dulcinea Technologies Corporation
Software of Elegance and Beauty
http://www.dulcineatech.com
quixote@xxxxxxxxxxxxxxxx

Other related posts: