Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2002-09-17 09:55:11


Beman Dawes wrote:
> At 05:57 AM 9/17/2002, Vladimir Prus wrote:
>
> >1. Say I have a path. I want to treat it as relative to some other
> >directory, if it is relative. That is, I want function
> >
> > path root ( const path& p, const path& r )
> >
> >which will work like
> >
> > root ( "/home/ghost/a" , "/home/ghost" ) = "/home/ghost/a"
> > root ( "a" , "/home/ghost" ) = "/home/ghost/a"
> >
> >How can I do that? I seems rather hard currently -- I see no way to join
> >two paths
>
> Operator <<= and operator << do that, if I understand your question.

Oh, I entirely missed the fact that operator << works with paths...
However, the following program on Linux says "Aborted".

#include <boost/filesystem/path.hpp>
#include <iostream>

using namespace std;
namespace fs = boost::filesystem;

int main()
{
     fs::path p1("/home/ghost"), p2("/a/b/c");

     cout << (p1 << p2).file_path() << "\n";
}

The problem is at
#7 0x0804c9fd in boost::filesystem::path::path (this=0xbffff878,
src=0x804f5d2 "/home/ghost")
     at ../src/path_posix_windows.cpp:186
186 m_path_append( src );

- Volodya


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