• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to ResolvingSymlinksInPath ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: How to ResolvingSymlinksInPath ?
      • From: Jens Alfke <email@hidden>
References: 
 >How to ResolvingSymlinksInPath ? (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Why does default NSDateFormatter in IB ignore thousands separator?
  • Next by Date: Re: [Solved] Crash in addSubview: when compiled with SDK > 10.9
  • Previous by thread: How to ResolvingSymlinksInPath ?
  • Next by thread: Re: How to ResolvingSymlinksInPath ?
  • Index(es):
    • Date
    • Thread