Boost logo

Boost :

From: Dylan Nicholson (dylan_nicholson_at_[hidden])
Date: 2002-03-19 23:49:38


 --- "Stewart, Robert" <stewart_at_[hidden]> wrote: > From: Brey, Edward D
> > > From: Stewart, Robert [mailto:stewart_at_[hidden]]
> > >
> > > I think the "basic" remove() should not throw an exception for the
> > > equivalent of ENOENT. That is, if the postcondition is
> > > satisfied, then
> > > remove() need not throw an exception, even if the file didn't
> > > exist when called.
> >
But how are you defining the post-condition - simply that no file of that name
can be found, or that it was definitely determined that there is no file in the
relevant directory of the specified name? The former might be true if a) the
directory doesn't exist or can't be read or b) the device is not responding.
Surely there are some preconditions that must be satisified too?
Anyhow how hard is it to write

if (exists(filename)) remove(filename);

Or even write a function to do this if you don't want to type an extra 20
characters...

I'm fully in agreement with you that 9 times out of 10 you don't care whether
remove really succeeds or not, but being forced to think about the situations
where you might care is, IMHO, a Good Thing.

Dylan

http://movies.yahoo.com.au - Yahoo! Movies
- Vote for your nominees in our online Oscars pool.


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