@Test public void testFindRoot() throws Exception { final LocalSession session = new LocalSession(new Host(new LocalProtocol(), new LocalProtocol().getDefaultHostname())); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); assertTrue(new LocalFindFeature(session).find(new Path("/", EnumSet.of(Path.Type.directory)))); }
@Override public boolean find(final Path file) throws BackgroundException { if(Files.isSymbolicLink(session.toPath(file))) { return Files.exists(session.toPath(file), LinkOption.NOFOLLOW_LINKS); } final boolean exists = session.toPath(file).toFile().exists(); if(exists) { if(!file.isRoot()) { try { if(!StringUtils.equals(session.toPath(file).toFile().getCanonicalFile().getName(), file.getName())) { return false; } } catch(IOException e) { log.warn(String.format("Failure obtaining canonical file reference for %s", file)); } } } return exists; }
LocalFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(Files.isSymbolicLink(session.toPath(file))) { return Files.exists(session.toPath(file), LinkOption.NOFOLLOW_LINKS); } final boolean exists = session.toPath(file).toFile().exists(); if(exists) { if(!file.isRoot()) { try { if(!StringUtils.equals(session.toPath(file).toFile().getCanonicalFile().getName(), file.getName())) { return false; } } catch(IOException e) { log.warn(String.format("Failure obtaining canonical file reference for %s", file)); } } } return exists; } }
LocalFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(Files.isSymbolicLink(session.toPath(file))) { return Files.exists(session.toPath(file), LinkOption.NOFOLLOW_LINKS); } final boolean exists = session.toPath(file).toFile().exists(); if(exists) { if(!file.isRoot()) { try { if(!StringUtils.equals(session.toPath(file).toFile().getCanonicalFile().getName(), file.getName())) { return false; } } catch(IOException e) { log.warn(String.format("Failure obtaining canonical file reference for %s", file)); } } } return exists; } LocalFindFeature(final LocalSession session); }
LocalFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(Files.isSymbolicLink(session.toPath(file))) { return Files.exists(session.toPath(file), LinkOption.NOFOLLOW_LINKS); } final boolean exists = session.toPath(file).toFile().exists(); if(exists) { if(!file.isRoot()) { try { if(!StringUtils.equals(session.toPath(file).toFile().getCanonicalFile().getName(), file.getName())) { return false; } } catch(IOException e) { log.warn(String.format("Failure obtaining canonical file reference for %s", file)); } } } return exists; } LocalFindFeature(final LocalSession session); @Override boolean find(final Path file); }
LocalFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(Files.isSymbolicLink(session.toPath(file))) { return Files.exists(session.toPath(file), LinkOption.NOFOLLOW_LINKS); } final boolean exists = session.toPath(file).toFile().exists(); if(exists) { if(!file.isRoot()) { try { if(!StringUtils.equals(session.toPath(file).toFile().getCanonicalFile().getName(), file.getName())) { return false; } } catch(IOException e) { log.warn(String.format("Failure obtaining canonical file reference for %s", file)); } } } return exists; } LocalFindFeature(final LocalSession session); @Override boolean find(final Path file);  }