• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Any better way to determine if file is executable?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Any better way to determine if file is executable? (From: Devon Ferns <email@hidden>)

  • Prev by Date: Re: "report a problem" dialog box
  • Next by Date: Re: Determine if App is launched thru alias?
  • Previous by thread: Any better way to determine if file is executable?
  • Next by thread: Re: Any better way to determine if file is executable?
  • Index(es):
    • Date
    • Thread