Re: Any better way to determine if file is executable?
Re: Any better way to determine if file is executable?
- Subject: Re: Any better way to determine if file is executable?
- From: "Shawn Erickson" <email@hidden>
- Date: Tue, 30 Oct 2007 11:50:19 -0700
On 10/30/07, Devon Ferns <email@hidden> wrote:
> I've searched the list archives and no one seems to have a good way to
> do this.
> As discussed before, NSFileManager's isExecutableAtPath: returns YES
> for directories and any other file with the execute bit set.
> This isn't what I want so I've had to fudge together a solution.
>
> Basically, I'm using NSTask and executing /usr/bin/file on all
> suspected executable files and parsing the output for Mach-O.
> BTW, can anyone tell me what the program "file" will output for CFM
> binaries? I don't know of any that I can test it on to see.
You could look up the on disk format for Mach-O and parse a small bit
of the files yourself and avoid calling out to file.
I bet you can find the source for file in the darwin source code
(<http://www.opensource.apple.com/darwinsource/>) which would make
your job a little easier.
-Shawn
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden