Boost logo

Boost Users :

From: Peter Klotz (peter.klotz_at_[hidden])
Date: 2003-04-21 16:37:31


Hi Beman

> Could you give a bit of background on the above? What operating system?
> Exactly what do you mean by "dangling link"? If your operating system has
> several kinds of links, which kind are you talking about?

Sorry that I did not explain my environment.

The operating system is Linux.
I am talking about symbolic links whose target was removed.

Something like:
touch xyz
ln -s xyz dangling_link
rm -f xyz

> For example, on Windows 2K
> (and presumably other Windows variants), certain files like the pagefile
> can't even be queried by is_directory() without an exception being thrown.

Here I see a difference.
One obtains a security_error when accessing the pagefile under Windows.
This seems reasonable since users have no access rights for the pagefile.

In the case of dangling links I obtain a not_found_error.
This seems to be a contradiction. First I find something (and obtain an
iterator) and without any interference from
outside is_directory() tells me it cannot find the object.
The problem is that directory_iterator refers to the link whereas
is_directory() and the following exception refer to the target (which is
missing).

So by catching the not_found_error I am unable to distinguish these two
cases:
1. Found a link but its target is missing
2. Found a file/directory but someone deleted it before is_directory() was
called

> >Should the use of directory_iterator under certain circumstances force
the
> >user to use the native operating system API?
>
> Yes - in cases where there doesn't seem to be any way to abstract the
> operation into a portable function it is better to leave it for an
> operating system specific function.

I agree.
What about adding a "non portable" error code for filesystem_error,
something like missing_target_error?
Okay, this would be an implicit is_link() function :-)

> >Wouldn't it be more consistent to skip links altogether when iterating?
>
> I'm not sure.
I am not sure as well.

> Non-pathological links seem to work as expected, and
> operating systems often detect and report pathological cases as errors,
> which seems to me to be reasonable behavior. OTOH, links aren't an area
> that has received a lot of scrutiny, so it may be that some change is
> needed.

Dangling links may be pathological but they are perfectly legal as far as
the OS and the filesystem is concerned (and they are always present when
nobody expects it).

So the only solution seems to be to add an is_link() function myself and
check for the presence of the link target.

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