Re: fileExistsAtPath with * to indicate random
Re: fileExistsAtPath with * to indicate random
- Subject: Re: fileExistsAtPath with * to indicate random
- From: Brady Duga <email@hidden>
- Date: Mon, 10 Mar 2008 10:05:03 -0700
On Mar 10, 2008, at 9:10 AM, Mr. Gecko wrote:
I'm needing my application to find out if ImageMagick is installed.
It is usually installed in the root directory(/) and it has the name
of ImageMagick-6.3.8.
As previously pointed out, that is probably a bad assumption to make.
I want it to detect it even if the version is 6.3.9. That way if
there are any updates with ImageMagick I wont have to update my
program for the new one. The only way I can think of doing it is
with fileExistsAtPath but I can't find out how to have a random
indicator or whatever it is called. I tried BOOL ImageMagick =
[[NSFileManager defaultManager] fileExistsAtPath:@"/ImageMagick*/"
isDirectory:YES];
But it does not seem to know * as a random indicator like PHP and
Terminal does. I can't seem to think of a way to do this so, if any
one can help me figure this out I would be very grateful.
Also, as previously pointed out, there is no auto-globing like that.
While this is probably not the best way to determine if ImageMagick in
installed (and no, I have no idea what a better way might be), you
could do something like:
NSString *imPath = @"/ImageMagick"
BOOL installed = [imPath completePathIntoString: &imPath
caseSensitive: NO matchesIntoArray: nil filterTypes: nil];
If 'installed' is true then it found a matching file, otherwise it
didn't. I am not entirely sure passing nil to filterTypes is legal -
the docs don't say, but it seems reasonable. Caveat: I have never
actually used this call, so there is a good chance it does not work
the way I think it does.
--Brady
_______________________________________________
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