private SymlinkResult getSymlinkBase ( final String base , final Path file ) throws IOException { int nameCount = file . getNameCount ( ) ; Path root = fileSystem . getPath ( base ) ; int rootCount = root . getNameCount ( ) ; Path f = file ; for ( int i = nameCount - 1 ; i >= 0 ; i -- ) { if ( Files . isSymbolicLink ( f ) ) { return new SymlinkResult ( i + 1 > rootCount , f ) ; } f = f . getParent ( ) ; } return null ; }
Returns true is some element of path inside base path is a symlink .