Boost logo

Boost :

From: Keith Burton (kb_at_[hidden])
Date: 2002-08-01 10:25:37


1) defining exists() as being reachable is unacceptable

2) in the documented spirit of the filesystem library , i.e. as a simple
to use a scripting language , then remove()
not requiring the path to exist is the correct ( i.e. least surprise )
definition. Thus avoiding the need to document an inevitable problem.
However it looks as though we will have to agree to differ on this.

Keith

-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Mattias Flodin
Sent: 01 August 2002 09:24
To: boost_at_[hidden]
Subject: Re: [boost] Review Request: Filesystem Library

On Thu, Aug 01, 2002 at 08:28:23AM +0100, Keith Burton wrote: <about
what remove() should do when the file no longer exists>
> It should do nothing and return nothing as the operation has succeeded

> in that the post condition is true.

The way I interpret the meaning of exists, in this context, it means "is
reachable". Let's say for instance that exists("/floppy/foo") returns
true because a disk is mounted to the /floppy dir that contains the file
foo. The disk is then unmounted, leaving the /floppy dir empty. Now,
exists("/floppy/foo") will return false, because the file is no longer
reachable. That doesn't mean the file no longer exists, or that it has
been physically deleted.

What I expect of remove() to do, however, is to physically remove the
file. Not to make sure it is no longer reachable. So, although !exists()
can be trivially listed as a post-condition of remove(), it is not the
whole truth. The whole truth is that it is not only unreachable, but
physically deleted.

> ( This being much preferable to an attempt to avoid the exception by
> doing if ( exists( ph ) ) remove( ph ) ; and the post condition not
> being true )

This kind of code is dangerous because the two subexpressions of the
condition are not evaluated in one atomic operation. Perhaps the
documentation should mention this, to prevent people from trying it.
exists() must be true at the point of calling remove(), not 0.5
nanoseconds before.

/Mattias

-- 
Mattias Flodin <flodin_at_[hidden]>  -  http://www.cs.umu.se/~flodin/ Room
NADV 102 Department of Computing Science Umeå University S-901 87 Umeå,
Sweden
--
"There are two ways of constructing a software design; one way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies.  The first method is far more difficult." -- C. A. R.
Hoare _______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost

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