[Haskell] Reading a directory tree

Keith Wansbrough Keith.Wansbrough at cl.cam.ac.uk
Tue Jun 22 16:02:48 EDT 2004


> BTW, one other caveat (which applies to all of the examples so far):
> doesDirectoryExist doesn't distinguish between directories and
> symlinks to directories. Consequently, any directory-traversal
> algorithm which uses doesDirectoryExist to identify directories will
> behave incorrectly in the presence of symlinks. In the worst case, you
> can get into an infinite loop.

symlinks aren't necessary to give an infinite loop: you can have upwards hard links as well (at least on *nix).  You have to keep a list of inodes you've already visited (per filesystem, of course).

--KW 8-)
-- 
Keith Wansbrough <kw217 at cl.cam.ac.uk>
http://www.cl.cam.ac.uk/users/kw217/
University of Cambridge Computer Laboratory.



More information about the Haskell mailing list