Re: determining binary files from text
Re: determining binary files from text
- Subject: Re: determining binary files from text
- From: Michael Gersten <email@hidden>
- Date: Fri, 08 Mar 2002 10:33:58 -0800
So, the old standby, guaranteed portable, old-style comment of
:use sh
isn't supported anymore?
Michael
(Remember: a file marked executable that doesn't have a magic number
is a shell script. #! is a kernel-handled magic number, and has been
since something like bsd 4.3.)
Sherm Pendley wrote:
>
>
On Thursday, February 28, 2002, at 03:12 PM, Ed Silva wrote:
>
>
> Unfortunately it is possible that someone could put binaries in a
>
> startup item folder, which causes my app to barf and die when it tires
>
> to parse it. So, how do I tell if a file is a binary or text?
>
>
Check the first two bytes - a script always begins with "#!" followed by
>
the path to the script interpreter.
Someone else said
>
Mach-o executables have as their first four bytes either MH_MAGIC,
>
MH_CIGAM, FAT_MAGIC, or FAT_CIGAM, as defined in mach-o/loader.h and
>
mach-o/fat.h. Executable shell scripts have #! for their first two
>
bytes.
>
>
However, better for your app not to barf and die when it encounters
>
something it can't parse. Someday somebody is going to put something in
>
there that isn't either one...
and I think I just did.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.