determining binary files from text
determining binary files from text
- Subject: determining binary files from text
- From: Ed Silva <email@hidden>
- Date: Thu, 28 Feb 2002 12:12:01 -0800
Hi all,
I have a bit of a problem: I need to be able to figure out if a
file is a binary or plain text.
Here's the problem that I ran into: I am working on a Cocoa
application to manage the /Library/StartupItems folders; you can
edit the scripts and plists and enable/disable items (changing the
/etc/hostconfig entry to '-NO-' or '-YES-', if there is one),
create new startup items, etc. It's pretty nifty, IMHO. :-)
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?
<RANT>
I think it's better to use a script for launching startup items so
that /etc/hostconfig can be used to enable/disable the item. What
if I don't want that particular thing to run? If there is a binary
in the startup item folder I have to move the directory to disable
it, if it's a script that checks for a hostconfig string all I have
to do is set that entry to -NO_ in the hostconfig file. Putting a
binary in the folder just makes life harder for users... And me.
You listening, Symantec? ;-)
</RANT>
The 'file' command says 'Mach-O executable ppc' for a binary, but
how does it determine that? I know that 'file' uses /etc/magic, but
I don't know how, can anyone clue me in? Or is there a Foundation
(or lower API) method for doing this?
TIA,
--Ed Silva
_______________________________________________
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.