Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-04-05 14:42:19


From: "Beman Dawes" <bdawes_at_[hidden]>
>
> To me, an io error does imply some kind of failure, and a serious one at
> that. Remember that errors reported by the system API call (stat() or
> similar) have been analyzed, and those that clearly indicate existance or
> not are not treated as errors. What is left are error codes that represent
> either hard errors, or conditions which are ambiguous as to the true status.

That's not entirely unreasonable, but it's a question of use
cases.

> I've been burned badly in the past by trying to continue after an io error,
> so really prefer errors to be announced nosily and as soon as possible. I'm
> also inclined to think that reporting a directory as !is_directory() when
> there is a permissions clash, even though it appears on a "ls" or file
> system browser as a directory, is likely to raise eyebrows and generate
> endless mistaken bug reports.

Such eyebrow positions and bug reports would indicate a failure
to understand permissioning. The key is to understand that
is_directory() returns true iff the supplied pathname is a
directory to the caller. That means it must exist, be
accessible, and be a directory. Anything else isn't a directory,
so far as the caller is concerned.

Also, don't forget that with other, more detailed means to get
information on a pathname, like the stat() (or whatever you
choose to call it) function, one can get more precise information
if warranted by the code.

I recall that your original notion for the Filesystem library was
to enable script-like coding in C++. Such code is less rigorous
than normal applications. That's not to say that it need be
sloppy, but it is often more forgiving. I'll again refer to my
years of writing shell scripts on *nix. The -d test never
generates a signal (the moral equivalent of an exception in C++
in this case); it just returns true or false. That simplicity
makes it easier to write scripts, though I'll grant that it does
mean you have to be a little careful to not make too many
assumptions about what ! -d means.

> But it looks from other's responses that I'm out voted. And it isn't just
> people who have commented on this list. I tested the Python os.path library,
> and its isdir() function doesn't even throw if the entire file system goes
> offline.

The number of votes is still pretty small, I think. I would
obviously not complain if you agreed with me, but I'd feel more
comfortable if there was more feedback.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

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