Boost logo

Boost :

From: Martin (adrianm_at_[hidden])
Date: 2005-12-30 03:49:25


> If an "exists(directory_iterator)" overload was supplied, it would be really
> easy to write "exists(itr)" when you meant "exists(itr->path())".

I assume you mean exists(*itr) instead of exists(itr->path())

> Functions with different semantics should have different syntax. At least
> that was the theory.

Don't agree in this case but it is your library. :-)

>Is the litter just to deal with exceptions coming out of directory_iterator
>constructors? Or are there other use cases needing excessive try/catch
>blocks?

"exists", all "is_*" functions and direcory_iterator all throws on access
denied so basicly a try/catch is needed for any use of these (at least for
me). Sometimes I can let the exception propagate up to a top level catch
handling filsystem corruption, network problems and race conditions but
generally not.

With the earlier code "exists" didn't throw and I created my own non-throwing
overload of is_directory "is_directory(path&, bool errorreturn)" but with the
new code I use status instead.

Ideally for me would be the following

// throws on error
is_directory(const path&);

// never throws (or is an implementation allowed to not cache status?)
is_directory(const directory_iterator&);

// don't throw and return errorreturn on error
is_directory(status, bool errorreturn = false);

Regarding the non-throwing directory_iterator. Couldn't the constructor return
something that compares equal to the end iterator but is carrying a status
member.


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