Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2004-03-19 13:20:40

At 02:23 AM 3/13/2004, John Torjo wrote:

>Dear boosters,
>I noticed that currently there's no way to get the relative path of path
>A related to path B.
>What I mean is, given two **complete** paths, to get the relative path
>of one related to the other.
>To give a real example, I have an application that starts in directory
>I have several dialogs that allow the user to browse for files. My
>requirement is, after the user browses for a file, to internally ALWAYS
>store the path relative to initial_path().
>Since there's no way to do this currently, I created my own function.
>Do you think it could be a useful addition to filesystem library?

It might be useful, but the problem is one of expectations. The function
you provided operates only on the lexical path representation; that's OK if
that is what is expected but could be a pretty rude shock to a programmer
not expecting that behavior.

For example, relative_to( "c:/foo", "C:/foo" ) returns "c:/foo", which is
probably not what was desired.

I'm definitely worried that relative_to() as proposed would come to be
viewed as fragile.

This is similar to the path equality issue. We are dealing with that by
introducing class path relational operators, working at a lexical level,
and a function equivalent() which actually performs filesystem operations
to determine if two paths refer to the same underlying object.

What do others think?


Boost list run by bdawes at, gregod at, cpdaniel at, john at