Boost logo

Boost Users :

From: Peter Klotz (peter.klotz_at_[hidden])
Date: 2003-04-14 15:45:55


The following is a part of the directory_iterator documentation:

"A path returned by dereferencing a directory_iterator is, if representing a
directory, suitable for.... If not representing a directory, the
dereferenced path is suitable for..."

So I would assume that dereferencing a directory_iterator and using
is_directory() should always be possible. This is not the case for a
dangling link.

In the example below is_directory() throws an exception when a dangling link
is encountered.

boost::filesystem::directory_iterator itDirEnd;
for (boost::filesystem::directory_iterator
itDir("/tmp");itDir!=itDirEnd;++itDir)
{
    if (boost::filesystem::is_directory(*itDir)) // throws an exception for
dangling links
        ;
}

Should the use of directory_iterator under certain circumstances force the
user to use the native operating system API? Wouldn't it be more consistent
to skip links altogether when iterating?

Best regards, Peter.


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