• 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: My private problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: My private problems


  • Subject: Re: My private problems
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sun, 20 Apr 2008 11:59:32 +0200


Le 20 avr. 08 à 10:46, stephen joseph butler a écrit :

On Sun, Apr 20, 2008 at 3:19 AM, Gerriet M. Denkmann <email@hidden >
wrote:


I need an absolute path.

So I do:

NSFileManager *fima = [ NSFileManager defaultManager ];
NSString *fileType = [ [ fima fileAttributesAtPath: path traverseLink: NO
]; fileType ];
if ( [ fileType isEqualToString: NSFileTypeSymbolicLink ] )
path = [ fima pathContentOfSymbolicLinkAtPath: path ];


The problem is: "/tmp" is converted to "private/tmp" (Note the missing
slash at the start).


Well, it's not "converted". In OS X, "/tmp" is a relative symbolic link.
-[NSFileManager pathContentOfSymbolicLinkAtPath:] calls something like
readlink(2) behind the scenes. So what you get back is the content of the
link... which is a relative directory name.



Short of hardcoding a change from "private" to "/private" - is there some Cocoa (or Carbon or bsd or whatever) way to get "/tmp" converted to "/private/tmp" (with the leading slash) ? (Same problem exists for /etc and /var).


You can do this:

[[path stringByDeletingLastPathComponent]
stringByAppendingPathComponent:[fima pathContentOfSymbolicLinkAtPath

:path]];


I think that will work.

Not if the link point to an absolute path.

NSString *absolute = [fima pathContentOfSymbolicLinkAtPath:path];
if (![absolute isAbsolutePath])
	absolute = [absolute stringByAppendingPathComponent:absolute];



_______________________________________________

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


References: 
 >My private problems (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: My private problems (From: "stephen joseph butler" <email@hidden>)

  • Prev by Date: Re: Should a Method set NSError* to nil when No Error?
  • Next by Date: Re: My private problems
  • Previous by thread: Re: My private problems
  • Next by thread: Re: My private problems
  • Index(es):
    • Date
    • Thread