protected Path convertToRelative(final Path path) { if (path != null) { final RelativePathService service = property().service(RelativePathService.class); if (service == null) { if (enclosed()) { for (Path root : getBasePaths()) { if (root.isPrefixOf(path)) { return path.makeRelativeTo(root); } } } else { final String pathDevice = path.getDevice(); for (Path root : getBasePaths()) { if (MiscUtil.equal(pathDevice, root.getDevice())) { return path.makeRelativeTo(root); } } } } else { return service.convertToRelative(path); } } return null; }
public FileSystemNode find(final Path path) { for (FileSystemNode root : this.roots) { final Path rootPath = new Path(root.getFile().getPath()); if (rootPath.isPrefixOf(path)) { return root.find(path.makeRelativeTo(rootPath)); } } return null; }