Boost logo

Boost :

From: Keith Burton (kb_at_[hidden])
Date: 2002-09-19 02:49:10


I believe that the issues mentioned below can be resolved by making all
paths absolute when constructed.

the path constructors is defined as :

        path( const char * name ) // relative to current
directory
        path( const char * name, const path & relative_to )

with this

        path( "foo", "/bar" )

   // gives absolute name on windows by using the drive of the current
directory when the path "/bar" is constructed

Obviously this style can be applied to an absolute function by defining

        absolute( "foo", "/bar" ) as being evaluated as absolute(
"foo", absolute( "/bar" ) )

and defining

        absolute( "" ) gives current directory

Keith

-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Beman Dawes
Sent: 19 September 2002 00:01
To: boost_at_[hidden]
Subject: Re: [boost] Filesystem Library: Formal Review

[snip]

I think there are actually three valid choices for supplying absolute
root
information:

   (1) The current directory (and drive, volume or other system_specific

root information.
   (2) An explicitly supplied path (via a second argument.)
   (3) initial_directory()

(3) can be coded explicitly as the second argument with the interface
having to make any special provision, but we might want to make it the
default behavior.

Another thing that has to be nailed down is what happens with various
boundary conditions. For example:

    absolute( "foo", "bar" ) // Oops, 2nd arg isn't absolute
    absolute( "foo", "c:" ) // Oops, 2nd arg isn't absolute on Windows
    absolute( "foo", "/bar" )// Oops, 2nd arg isn't absolute on Windows
    absolute( "" ) // What does this return?

The third one is particularly tricky because it is perfectly valid for
POSIX but not for multi-rooted systems like Windows.

Also, note that the 2nd and 3rd are system specific, but I don't think
that
should be implied.

Basically, it is necessary to allow system specific paths, and access to

the current directory, drive, etc. but they should always be slightly
ugly
(so people think twice about using them), and easy to find with
grep-like
tools (so they can be found in source code). IOW, same rationale as the
new-style cast syntax.

A another question is that in effect we are making the current directory

available by calling absolute() with the right arguments, so would it be

better (in addition to absolute()) to just go ahead and add a
current_directory() function? Or a special path constructor?

And finally, how do we specify absolute() so that it still gives
reasonable
behavior on an operating system which has no concept of current
directory?

Need to think about it a bit more.

Thanks,

--Beman


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