On Feb 16, 2007, at 12:06 PM, Charles Yeomans wrote:

On Feb 16, 2007, at 1:04 PM, [EMAIL PROTECTED] wrote:

How would I go about determining if a given folderitem is an executable file? This only has to work on OSX (10.3+).

It depends on what you mean. Other people have said how to tell whether the file has execute permissions set. But those can be set for any file. If, on the other hand, you want to know how to tell whether a file consists of executable code, then that's a little more difficult. If the first eight bytes of the file are 'Joy! peff', then it is probably a PEF executable. Mach-O executables also begin with a header whose structure is documented in Apple's Mach-O docs, but I don't know offhand an easy test for Mach-O format.

Use the "file" command line tool:

        shell.Execute "file " folderitem.shellPath

If the response includes things like:

        filename: Mach-O universal binary with 2 architectures
        filename: Mach-O executable i386
        filename: Mach-O executable ppc
        filename: header for PowerPC PEF executable

It's a binary file. Combine that with the permissions bits discussed previously and you'll have a pretty good idea of the type of file you're dealing with.

HTH,
Tim
--
Tim Jones
[EMAIL PROTECTED]

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to