> On 2 Nov 2016, at 20:40, Stephane Sudre <dev.iceb...@gmail.com> 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 (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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to