On Sep 21, 2008, at 6:36 AM, Michael Ash wrote:

On Sat, Sep 20, 2008 at 12:57 PM, Tommy Nordgren
<[EMAIL PROTECTED]> 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,
        Not true. With the given command line, find will return absolute paths.
So this anomaly is easily detected when parsing find output

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.
Firstly you can just increase the soft limit. Hard limits on Mac OS X is very generous. Secondly it would fail because maximum number of processes have been reached,
you can simply retry later.
I have never had a process break because it has reached the maximum allowed cpu-time,
except in situations where I've deliberately set it very low,


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.

Using Spotlight to search for applications won't work, because some open-source
packages install apps in directories that's not searched by spotlight,
        For example - the default install path for Qt is in directory
/usr/local/Trolltech/Qt-<version-nr>
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

-----------------------------------

See the amazing new SF reel: Invasion of the man eating cucumbers from outer space. On congratulations for a fantastic parody, the producer replies : "What parody?"

Tommy Nordgren
[EMAIL PROTECTED]



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to