• 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: telling when a directory is really a bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: telling when a directory is really a bundle


  • Subject: Re: telling when a directory is really a bundle
  • From: John Stiles <email@hidden>
  • Date: Mon, 22 Oct 2007 08:30:05 -0700

I think your final implementation is likely to be using NSWorkspace, as others have suggested, not NSAppleScript.

However, for the benefit of the archives, I'd like to point out that the construct you have below is very unsafe.

If the path has any non-MacRoman characters in it, the AppleScript will fail entirely.

If the path has QUOTES in it, then the result is undefined--the user's path name will end up being interpreted as AppleScript commands, which in the wrong hands could be used as an exploit. You don't want your app to be known for having a security hole :(

The workaround is to represent the path as ‹‹utf8›› data.

On Oct 22, 2007, at 5:35 AM, Martin Redington wrote:


According to the docs at

http://developer.apple.com/documentation/CoreFoundation/Conceptual/ CFBundles/Concepts/BundlesAndFinder.html#//apple_ref/doc/uid/ 20002127-BAJIBGGC

A directory is a package if:

1) it has a known suffix .app, .bundle, etc.
2) it has the bundle bit set
3) it has a known structure indicating its a bundle

I'm trying to construct some AppleScript (from my Cocoa app) to do a Finder Get Info on an item.

tell application "Finder"
set macpath to POSIX file "%@" as text
open information window of %@ macpath
activate
end tell

I seem to need to specify "file" or "folder" in the second slot, and AppleScript errors if I specify folder for a bundle.

So, given a directory, how can I tell if it is a bundle or not. I've tried looking at the bundle bit, but in my /Applications directory, only four .apps seemed to have it turn on.

I could implement 1, 2, and 3 above myself, but that would be hacky.

I could try and initialise a CFBundle or NSBundle with the directory, but that is pretty nasty too.

Is there any easier or cleaner way to programmatically determine whether a directory is a bundle or not?

If I do have to implement it myself, is there any way to get the "known" suffixes?






_______________________________________________

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:
40blizzard.com


This email sent to email@hidden

_______________________________________________

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


  • Follow-Ups:
    • Re: telling when a directory is really a bundle
      • From: Martin Redington <email@hidden>
References: 
 >telling when a directory is really a bundle (From: Martin Redington <email@hidden>)

  • Prev by Date: Re: launchd daemon and Distributed Objects.
  • Next by Date: Re: Cannot Connect to NSDrawer
  • Previous by thread: Re: telling when a directory is really a bundle
  • Next by thread: Re: telling when a directory is really a bundle
  • Index(es):
    • Date
    • Thread