On Mar 15, 2007, at 6:00 PM, Andrew Burton wrote:
Nope, there
is no such header in any UNIX implementation that I'm
aware of. The "magic number" you speak of isn't part of any
header...the "file" program opens the target file, looks at the first
few bytes, and then looks up the pattern in its database to arrive at
an *educated guess* as to the type of file it's looking at...for
example, if bytes 7-10 of the file are 0x4a464946 (ascii "JFIF"), it
is most likely (but not definitely!) a JPEG image file. Similarly,
if bytes 1-6 are 0x474946383961 (ascii "GIF89a") the file is most
likely a v89a GIF image file, and if bytes 1-8 are 0xfeedface, it's a
Mach-O executable from a MacOS X system.
It is important to understand, though, that this has nothing at
all to do with the operating system, and there is no common header
format of any sort. It just so happens that many types of files are
consistent in what their first few bytes contain.
Is the 0xfeedface ascii or hex?! ;) Was that deliberate or purely
accidental, and who was behind it?
It's hex. There's no way that could've been accidental. I have
no idea who was responsible for it, though.
I agree with what you are saying. When i was writing a
program that
involved using images on my Amiga I discovered that the .IFF files
always had the same ASCII within the first 20 bytes (well bytes 1-8
and 16-20, or thereabouts). I never realised that the same was true
about most file types.
It stands to reason that this would be the case for many non-human-
readable files.
-Dave
--
Dave McGuire
Port Charlotte, FL