Professional Web Applications Themes

Strange cocoa error: iecutableFileAtPath - Mac Programming

hey all-- I'm using NSFileManager's iecutableFileAtPath to sort a list of paths into applications and non-applications. For some reason, though, it seems to consider nearly everything an executable, even most folders. Here's how Im using it: if ([[NSFileManager defaultManager] iecutableFileAtPath:add]) { ..put in app category.. } else { ..put in docs category.. } I know that "add" is a valid path, because I'm getting it from the Finder in a drag-n-drop, *plus* I'm using it to create an FSSpec and an AliasHandle (both of which are created without error). Are there any obvious caveats to this message? Any known bugs? ...

  1. #1

    Default Strange cocoa error: iecutableFileAtPath

    hey all--

    I'm using NSFileManager's iecutableFileAtPath to sort a list of paths
    into applications and non-applications. For some reason, though, it
    seems to consider nearly everything an executable, even most folders.
    Here's how Im using it:

    if ([[NSFileManager defaultManager] iecutableFileAtPath:add]) {
    ..put in app category..
    } else {
    ..put in docs category..
    }

    I know that "add" is a valid path, because I'm getting it from the
    Finder in a drag-n-drop, *plus* I'm using it to create an FSSpec and an
    AliasHandle (both of which are created without error).

    Are there any obvious caveats to this message? Any known bugs? Im using
    10.2.8 if that helps.

    --
    |\/| /| |2 |<
    mehaase(at)sas(dot)upenn(dot)edu
    Mark Guest

  2. #2

    Default Re: Strange cocoa error: iecutableFileAtPath

    In article <upenn.edu>,
    Mark Haase <net> wrote:
     

    I think this method looks at the Unix "x" bit on files. Unix
    directories typically have this bit set. An "ls -l" of the directory
    you're looking at would clear this up, but this is the most likely
    reason for what you're seeing.

    --
    Tom "Tom" Harrington
    Macaroni, Automated System Maintenance for Mac OS X.
    Version 2.0: Delocalize, Repair Permissions, lots more.
    See http://www.atomicbird.com/
    Tom Guest

  3. #3

    Default Re: Strange cocoa error: iecutableFileAtPath

    In article <tph-751468.16010216062004localhost>,
    Tom Harrington <no.spam.dammit.net> wrote:
     

    Tom, I think you're right. I just did a
     

    and all of the directories that I was trying to sort have +x. I recall
    the API docs saying that iecutableFileAtPath checks to see if the
    "underlying operating system" thinks its executable. I thought they
    meant a check for Mach-O, etc. I guess not.

    Thanks for the pointer.

    I will add a check to see if a file is a directory when it has +x set.

    --
    |\/| /| |2 |<
    mehaase(at)sas(dot)upenn(dot)edu
    Mark Guest

  4. #4

    Default Re: Strange cocoa error: iecutableFileAtPath

    > In article <tph-751468.16010216062004localhost>, [/ref]

    For the benefit of future Googlers:

    I initially added a check to see if a path with +x was a directory, but
    then I realized that all ".app" bundles *are* directories. So I added
    another check to look for the ".app" extension. This worked pretty well,
    but I found that some applications use application bundles without using
    the ".app" extension. (Acrobat Reader 5, eg.) Therefore, I added a new
    check to see if a +x directory has a "/Contents/MacOS" subdirectory,
    since all bundles must have one.

    This sounds kind of flimsy, and its not exactly the 100% kosher way to
    do it. (For instance, this isn't how the Dock does it, as I will explain
    in a second.)

    For the curious, I tried taking a new, untitled folder and adding a .app
    extension. When you double click on this, it gets the grow effect (This
    is in jaguar, by the way) but of course nothing happens. If, however,
    you add a /Contents/MacOS subdirectory to the folder before giving it
    the .app extension and then double click on it, Finder gives a strange
    error (#1000). Strange, but true.

    Mark

    --
    |\/| /| |2 |<
    mehaase(at)sas(dot)upenn(dot)edu
    Mark Guest

  5. #5

    Default Re: Strange cocoa error: iecutableFileAtPath

    In article <upenn.edu>,
    Mark Haase <net> wrote:
     

    Instead, use Launch Services, call LSCopyItemInfoForURL, and check the
    kLSItemInfoIsApplication flag. That'll give you the results your users
    would expect.

    Hope this helps,
    Eric

    --
    Eric Albert stanford.edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

  6. #6

    Default Re: Strange cocoa error: iecutableFileAtPath

    In article <upenn.edu>,
    Mark Haase <net> wrote:
     

    This is a terrible idea. Call LaunchServices to find out if you have an
    application. LSCopyItemInfoForURL is probably the API you want.

    hth

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  7. #7

    Default Re: Strange cocoa error: iecutableFileAtPath

    Eric Albert <stanford.edu> wrote:
     
    >
    > Instead, use Launch Services, call LSCopyItemInfoForURL, and check the
    > kLSItemInfoIsApplication flag. That'll give you the results your users
    > would expect.[/ref]

    Oops, that's what I was going to say. All of this has been rehashed
    before, so you could have saved yourself some trouble with a search. For
    example:

    http://cocoa.mamasam.com/COCOADEV/2002/07/1/38944.php

    m.

    --
    matt neuburg, phd = com, http://www.tidbits.com/matt/
    AppleScript: The Definitive Guide
    http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
    Read TidBITS! It's free and smart. http://www.tidbits.com
    matt Guest

  8. #8

    Default Re: Strange cocoa error: iecutableFileAtPath

    In article <upenn.edu>,
    Mark Haase <net> wrote:
     

    No, that's not right at all. There are a number of variants of bundles.
    Not all are applications, and not all have Contents/MacOS.

    Use Launch Services. Apple's engineers figured out what makes an
    application so you didn't have to. :)

    -Eric

    --
    Eric Albert stanford.edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

  9. #9

    Default Re: Strange cocoa error: iecutableFileAtPath

    In article <1gfilpx.1bvn1wr1r5btlyN%com>,
    com (matt neuburg) wrote:
     

    My apologies..I didn't even bother searching for this first. (hangs head
    in shame :)

    My outlandish hack is clearly a bad idea, I'll use Launch Services in my
    app. Thanks for the URL...

    --
    |\/| /| |2 |<
    mehaase(at)sas(dot)upenn(dot)edu
    Mark Guest

Similar Threads

  1. Cocoa ; NSString -substringToIndex strange error
    By Florian in forum Mac Programming
    Replies: 14
    Last Post: January 5th, 02:23 PM
  2. Strange error
    By Rush in forum PHP Development
    Replies: 1
    Last Post: September 16th, 07:38 PM
  3. [PHP] Strange error
    By Martin Towell in forum PHP Development
    Replies: 1
    Last Post: September 16th, 09:49 AM
  4. Strange Error
    By Fred in forum Windows Networking
    Replies: 2
    Last Post: August 11th, 07:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139