java - How to protect Files.walk from symbolic links recursion? -
how protect files.walk symbolic links recursion? using java or shell.
okay, follow links.
stream<path> stream = walk(startpath, maxdepth, filevisitoption.follow_links);
however check every directory whether symbolic link:
files.issymboliclink(path) && fles.isdirectory(path)
use
path realpath = path.torealpath();
then keeping list of directories on in, ancestors, 1 prevent recursion. doing every directory check in ancestors, when symbolic link somewhere in list/current path.
a > b > start:c > d > e > symbolic:f=a > b > c
(this still not prevent visiting directory twice, same or subdirectory linked without recursion.)
Comments
Post a Comment