Re: Normalizing a path containing a symlink
Re: Normalizing a path containing a symlink
- Subject: Re: Normalizing a path containing a symlink
- From: Mike Abdullah <email@hidden>
- Date: Sat, 16 Nov 2013 18:24:52 +0000
How about using -fileReferenceURL on everything? That won't give you a normalized *path* as such, but should give you consistent URLs for identifying individual files
Mike.
Sent from my iPhone
> On 14 Nov 2013, at 03:27 am, Rick Mann <email@hidden> wrote:
>
> In my iOS app, I create a directory in the user’s Documents directory, and then later iterate the contents of that directory. The problem is that on iOS, that directory has a path like “/var/stuff/Documents/Dir”, and when I iterate it, the resulting contents have paths like “/private/var/stuff/Documents/Dir/item”.
>
> This is fine, except that there comes a point where I have to compare my original “/var/…” path to one of the ones I've found, and get the relative part. This fails, since my path starts with "/var", and the items' paths start with "/private".
>
> Is there a way to normalize a path such that any symbolic links in it are resolved and the "real" path is created? I tried -[NSURL URLByResolvingSymlinksInPath], but that either doesn't work, or strips off the "/private" of the result. That is, I get a "/var" path.
>
> Alternatively, I can strip "/private" off any path I get while iterating, but that strikes me as fragile.
>
> Oh, it turns out I can use -URLByResolvingSymlinksInPath on the items returned while iterating the directory.
>
> Whatever it is, it's messy.
>
> --
> Rick
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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