Boost logo

Boost :

From: Carlo Wood (carlo_at_[hidden])
Date: 2004-09-02 09:00:26


On Thu, Sep 02, 2004 at 02:31:46PM +0100, Ben Hutchings wrote:
> Beman Dawes <bdawes_at_[hidden]> wrote:
> > At 01:53 PM 8/30/2004, Carlo Wood wrote:
> > >My idea on this was (and still is) that it is possible to convert
> > >a relative path to an absolute path (automatically) by adding an
> > >absolute path object reference to the relative path object.
> >
> > Yes, as long as you know the absolute path reference. Is the absolute
> > path reference known for all operating systems? I'm not sure about
> > that. For example, there have been multi-rooted systems that didn't
> > have a concept of "current drive". How would that work?
> <snip>
>
> Further, I know of one OS that supports directories but not a current
> directory: Windows CE. All paths passed to its filesystem functions
> must be absolute.

That would work a lot better with the 'relative_path / native_path'
approach: all system calls would be done with absolute paths.

boost::filesystem figures out the 'current directory' at application
start (if only being the directory that the application itself is in;
special code can be added for each supported OS separately if needed).
This directory is returned by fs::initial_path (I think it was called).
The documentation urges one to use this rather then 'current working
directory' and it is the default for fs::complete.
For the same reason as stated in the current documentation, I'd urge
to use this (already existing) fs::initial_path as completion 'root'
when a system call is about to be made for a relative path that is
not explicitely tied to a user defined (absolute) native_path object.

This means that code like:

fs::path p("foo");
if (fs::exists(p))

works on most systems, but fails on Windows CE with the current
implementation. You'd need to do explicitely:

fs::path p("foo");
if (fs::exists(fs::complete(p)))

But this would work on Windows CE just fine:

fs::relative_path p("foo");
if (fs::exists(p))

Again prove that it is more robust.

-- 
Carlo Wood <carlo_at_[hidden]>

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