Re: Best way to build relative pathname?
Re: Best way to build relative pathname?
- Subject: Re: Best way to build relative pathname?
- From: Greg Titus <email@hidden>
- Date: Mon, 12 May 2003 09:14:14 -0700
On Monday, May 12, 2003, at 05:30 AM, M. Uli Kusterer wrote:
yes, I found NSPathUtilities. But what I actually need is to go
FROM:
"/Users/witness/Documents/file.jpg"
and "/Users/witness/"
TO:
"Documents/file.jpg"
Where the paths can be arbitrary. What I'm currently doing is finding
the range of the second path (folder path) in the first path (file
path) and then delete that range from the string, which gets me the
proper result in the most common case.
Sadly, if the file path was "/Users/file.jpg", the correct relative
pathname would be "../file.jpg", which this obviously won't yield.
See OmniFoundation's NSString-OFPathExtensions method
-relativePathToFilename:, which does exactly what you are asking for
here.
Hope this helps,
- Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.