Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2002-09-18 10:37:47


Beman Dawes wrote:
> At 04:07 AM 9/18/2002, Vladimir Prus wrote:
>
> >Speaking terms of posix paths, I want
> >
> > join("/home/ghost", "a/b") = "/home/ghost/a/b"
> > join("/home/ghost", "/a/b") = "/a/b"
>
> Sounds like you want the [make_]absolute() function we have been
> discussing in another thread. The order of the arguments is reversed,
> but other than that the functionality seems the same.

Yes, the two argument form of 'absolute' is close to what I want.

> > int main()
> > {
> > fs::path p1("/home/ghost", fs::system_specific),
> > p2("/a/b/c", fs::system_specific),
> p3("a/b/c");
> cout << absolute(p2, p1).file_path() << "\n";
> cout << absolute(p3, p1).file_path() << "\n";
> > cout << (p1 << p2).file_path() << "\n";
> > }
>
> The output should be:
>
> /a/b/c
> /home/ghost/a/b/c

Good.

> /home/ghost/a/b/c

Err...
>
> Note that last one demonstrates a deliberate feature rather than a bug.
> To make that clearer, the following has been added to the append docs: >
> Rationale: It is not considered an error for rhs to include a
> system-specific-root because it might relative, and thus valid.
> For example, on Windows, the follow must succeed:
>
> path p( "c:", system_specific );
> p <<= path( "/foo", system_specific );
> assert( p.generic_path() == "c:/foo" );

This still sounds strange to me. Your example for windows makes perfect
sense, but the POSIX example is odd. Let's assume, in your example
above, that p3 is also created from system specific path. Then

   (p1 << p2).file_path()
and
   (p1 << p3).file_path()

would be equal, althought p2 and p2 were created from radically
different system specific paths. I think it should be either error, or
those two file paths should not be the same.

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk