Re: How to ResolvingSymlinksInPath ?
Re: How to ResolvingSymlinksInPath ?
- Subject: Re: How to ResolvingSymlinksInPath ?
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Thu, 03 Nov 2016 13:36:56 +0700
> On 2 Nov 2016, at 20:40, Stephane Sudre <email@hidden> wrote:
>
> https://www.cocoawithlove.com/2010/02/resolving-path-containing-mixture-of.html
I finally came up with this (all error checking removed):
- (NSString *)resolvedPathFor: (NSString *)rawPath
{
NSURL *url = [ NSURL fileURLWithPath: rawPath ];
NSArray *pathComponents = url.pathComponents;
NSError *outError;
NSURL *urlIter = nil;
for ( NSString *pathComponent in pathComponents )
{
NSURL *uTemp = urlIter == nil ? [ NSURL fileURLWithPath: pathComponent ] :
[ urlIter URLByAppendingPathComponent: pathComponent ];
urlIter = [ NSURL URLByResolvingAliasFileAtURL: uTemp options: 0 error: &outError ];
BOOL ok = [ urlIter checkResourceIsReachableAndReturnError: &outError ];
};
return urlIter.path;
}
This should handle /tmp, aliases, symlinks and any combination thereof.
Kind regards,
Gerriet.
_______________________________________________
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