Boost logo

Boost :

From: Carlo Wood (carlo_at_[hidden])
Date: 2004-08-18 15:59:28


On Wed, Aug 18, 2004 at 02:09:56PM -0400, Jeremy Maitin-Shepard wrote:
> The standard Windows path handling code in boost.filesystem treats the
> ("portable" format) path /usr as the Windows path "\usr", namely the usr
> subdirectory of the root directory of the current drive/volume.

Sure. That is what I said. On windows, "/usr" would in effect be
expanded to "letter:/usr" where <letter> is the (current) drive/volume root
directory. That isn't different from what it does now.

Only on cygwin the behaviour would change, and "/usr" would refer to
"C:/cygwin/usr" rather than "C:/usr". If someone really wanted to
specify a path that is a WINDOWS path (rather non-portable) then he
has to make sure that path is complete before using it. For example,
he could use "C:/Program Files" and would just access that directory,
while using "/Program Files" would not work (anymore).

I don't consider that a problem however. People who want to specify
windows paths on cygwin might as well use complete paths - it is more
important that one can ALSO use POSIX paths (like "/usr").

[...]
> If it followed these semantics, there would be no reason to define
> BOOST_POSIX when compiling Boost for cygwin, since the only effect would
> be that certain paths become illegal, no new paths become legal, and all
> legal paths refer to the same files.

Not entirely true - the result of 'current_path()' would still change from
"C:/cygwin" to "/".

> Consider, however, these alternate
> semantics for boost filesystem path handling on Cygwin:
>
> When compiled with BOOST_WINDOWS:
>
> "/" refers to the root directory of the current drive/volume
>
> "letter:/" refers to the <letter> drive/volume root directory
>
> When compiled with BOOST_POSIX:
>
> "/" refers to the Cygwin root directory
>
> "letter:/" refers to the <letter> drive/volume root directory

My problem with this is that the behaviour of boost::filesystem
then depends on how it was compiled; that means in at least
that no shared library (or dll) may be produced: it should always
be a static library. Otherwise a program can work on one machine
and fail on the next because the filesystem lib uses different
semantics.

More over, relying on "/" to refer to the root directory of the
current drive/volume, on a multi-root system SHOULD be deprecated,
because it is 'kinky' to use the term used in the documentation of
boost::filesystem. A programmer should always use either complete
paths or paths relative to the initial directory (the working directory
at program start). Using "/" is not safe.

My proposal would be to have this behaviour:

Whether compiled with BOOST_WINDOWS or BOOST_POSIX:

"/" refers to the root directory of single root systems. If the system
    is not a single-root system then it should throw. However, if
    the system is cygwin, then it should be the cygwin root.

"letter:/" refers to the <letter> drive/volume root directory on
    multi-root systems. If the system is not a multi-root system
    then it should throw*) On cygwin this would be the windows path.

*) When being used for an operation; not when handling a 'path'.

-- 
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