Re: Converting an Absolute path to a relative path?
Re: Converting an Absolute path to a relative path?
- Subject: Re: Converting an Absolute path to a relative path?
- From: Chris Ridd <email@hidden>
- Date: Sat, 18 Sep 2004 19:33:48 +0100
On 18/9/04 6:39 pm, M. Uli Kusterer <email@hidden> wrote:
> At 19:26 Uhr +0200 18.09.2004, Stéphane Sudre wrote:
>> Did I reinvent the wheel or is there really not
>> a method in NSString which allows to convert an
>> absolute path to a relative one provided a
>> reference path?
>
> I didn't find one, but I wrote one for Verpack,
> in case anyone needs one. I've also written one
> that will re-assemble two such paths again,
> taking into account any "../" sequences.
This sort of conversion is notoriously difficult to get completely right...
Are you dealing correctly with multiple slashes in a path (e.g. foo//bar)
and links?
I *think* the only foolproof way to do it is to use chdir to the absolute
path, and then chdir("..") until you end up in the folder with an inode the
same as the intended base.
Sorry if I'm giving you both egg-sucking instructions ;-)
Cheers,
Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden