If you're not concerned about mount-path inclusion, where Library may be on another volume but mounted at that point, use rangeOfString:options:range: with an anchored search option and range consisting of the full length of the laurent-ending string. You have three possible results: not found (no), lengths are equal (yes), or length to search is larger than the length found (maybe). In that last case, see if the next character after the found range is a path separator. If it is, (yes); if not, (no). The method hasPrefix: is pretty much a convenience for this call but does not differentiate in the last case and would always return yes.
On 03/18/2011 2:59 PM, "Laurent Daudelin" <[email protected]> wrote: >I have a couple of ideas using "pathComponents" but does anybody have a >quick way to find if a given path is contained in another path, e.g. if >"/Library/Users/laurent/Library" is contained in "/Library/Users/laurent" >(in this case, it is)? > >-Laurent. >-- >Laurent Daudelin >AIM/iChat/Skype:LaurentDaudelin >http://www.nemesys-soft.com/ >Logiciels Nemesys Software >[email protected] > _______________________________________________ Cocoa-dev mailing list ([email protected]) 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]
