Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2004-12-05 17:57:10


At 05:54 PM 12/1/2004, Martin Slater wrote:
>
>Hi,
>
>I've been using boost.filesystem and have come up on a problem with
>exists(). Basically on a windows system it will return true if asking
>whether a file exists on a non-existent share. The problem is at,
>operations_posix_windows.cpp:327. There should (?) be an additional
>check against ERROR_BAD_NETPATH as well.

Fixed in CVS. A test case was also added to operations_test.cpp

> The fuzziness of this function
>is quite disturbing as shown by the following comment in the code
> return false; // GetFileAttributes failed because the path
>does not exist
> // for any other error we assume the file does exist and fall
>through,
> // this may not be the best policy though... (JM 20040330)

Yes, we got caught flatfooted by the exists() special cases. My fault
entirely.

Since then there has been further discussion, with the conclusion that a
second function is needed, tentatively to be named "is_accessible". It
would return true only if GetAttributes() does not return an error.

>The windows docs don't really help that much by not specify exactly what
>the failures can be though. Personally I think it should always return
>false on GetAttributes() error to avoid false positives and the expense
>of the possible false negatives, but we need a list of all possible
>errors to be sure that this is the right thing to do.

Yes, that's what is_accessible() would do. Part of the reason for not just
diving in and implementing it is your concern that we have considered all
possible errors.

>Oh and any chance you can put in serialization support for
>boost::filesystem::path? I've done it locally and the code is trivial
>but it would be nice to have it out the box.

Would you care to contribute your code? I'd love to add serialization
support. But I haven't had a chance to use the serialization library yet,
so some suggested code would light a fire under me.

>Anyhow, thanks for a great library (filesystem and the rest of boost).

Thanks! The filesystem library's users have constantly been the inspiration
for improving it.

--Beman


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