Re: Finding other apps' paths - deterministically!
Re: Finding other apps' paths - deterministically!
- Subject: Re: Finding other apps' paths - deterministically!
- From: "Michael Ash" <email@hidden>
- Date: Sun, 21 Sep 2008 00:36:23 -0400
On Sat, Sep 20, 2008 at 12:57 PM, Tommy Nordgren
<email@hidden> wrote:
> Use NSTask with the command line find -x / -name '*.app'
> Do this on a separate thread, and cache the result.
I highly recommend against this approach. One problem is that it will
fail badly if any of the returned paths contain the \n character,
which is a perfectly legal path character. For another it will fail if
the new process would exceed the user's process limit, a limit which
tends to be much lower than most other resource limits and thus much
easier to encounter in realistic situations.
For the original problem, I'd recommend using something like
LSCopyApplicationURLsForURL() if it's at all possible. Of course maybe
you have data that isn't good for that, but if you can use it then
that's the way to go.
If you must search the disk, use Spotlight if you can. It will be
vastly faster than anything else. The downside is that it won't work
if indexing is disabled or if the desired application is in an
excluded directory.
If you must search the whole disk without Spotlight, use
NSDirectoryEnumerator. Or if you're the sort who likes to use
unsupported private functions, you may be interested in the discussion
near the bottom of http://www.cocoadev.com/index.pl?AllApplications
Mike
_______________________________________________
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