Files.walkFileTree() visits a file leading to a loop with LOOP_DETECT option enabled
Rajendra Gutupalli
Rajendra.Gutupalli at Sun.COM
Wed Aug 6 01:26:41 PDT 2008
Hi Alan,
I have a entry in directory structure that references ancestor of the
directory (this is a loop according to spec) but still it is being
visited by Files.walkFileTree().
I created a directory structure as follows. /java/DirA/dirClink is a
link file which points to /java/DirB/DirC and /java/DirB/DirC/dirBlink
points to /java/DirB.
Actually if there is link which points to ancestor that is not being
visited by Files.walkFileTree(). Here is the scenario where it visits.
Directory Structure:
/java
DirA
dirClink -> /java/DirB/DirC
DirB
DirC
dirBlink -> /java/DirB/ (This is the link which
should not be visited at all)
When I run code with all FileVisitOptions, I got the following print
bash-3.00$ ./jdk1.7.0/bin/java TreeTest03 /java/DirA
pre dir /java/DirA
pre dir /java/DirA/dirClink
pre dir /java/DirA/dirClink/dirBlink
post dir /java/DirA/dirClink/dirBlink
post dir /java/DirA/dirClink
post dir /java/DirA
So my query here is- Should pre and post VisitDirectory() be opened for
the loop file /java/DirA/dirClink/dirBlink?
>> when I run the code with /java/DirB input , then the pre and post
VisitDirectory() methods will not be called for the loop file
/java/DirB/dirBlink
bash-3.00$ ./jdk1.7.0/bin/java TreeTest03 /java/DirB
pre dir /java/DirB
pre dir /java/DirB/DirC
post dir /java/DirB/DirC
post dir /java/DirB
Thanks
Rajendra.
More information about the nio-dev
mailing list