|
Boost Users : |
From: me22 (me22.ca_at_[hidden])
Date: 2005-02-20 13:21:25
On Sun, 20 Feb 2005 11:28:23 +0100, Matthias Kaeppler
<nospam_at_[hidden]> wrote:
> I wonder if there is any means of telling
> boost::filesystem::directory_iterator to skip broken symlinks. It's sort
> of an annoyance working with them, since operations like is_directory
> will throw when invoked on a broken symlink.
> I am keeping a vector of boost::filesystem::pathS, and as soon as I
> operate on a broken symlink, an exception will be thrown. I do catch it,
> but that doesn't really help since the program will return from the
> method where the exception was thrown. I would find it much more
> convenient to simply skip these broken files, instead of jumping out of
> the procedure (IMO it's not even exceptional behavior, dead symlinks are
> pretty common).
http://boost.org/libs/filesystem/doc/operations.htm#symbolic_link_exists says:
* ph not present: !exists(ph) && !symbolic_link_exists(ph)
* ph present and is not a symbolic link: exists(ph) &&
!symbolic_link_exists(ph)
* ph present and is a symbolic link to a non-existent file or
directory: !exists(ph) && symbolic_link_exists(ph)
* ph present and is a symbolic link to an existing file or
directory: exists(ph) && symbolic_link_exists(ph)
Or, less elegantly, you could always catch the exception in the procedure.
Hope that helps,
- Scott McMurray
( Disclaimer: I'm new here )
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net