@Override
    public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
        final AttributedList<ch.cyberduck.core.Path> paths = new AttributedList<>();
        final java.nio.file.Path p = session.toPath(directory);
        if(!Files.exists(p)) {
            throw new LocalExceptionMappingService().map("Listing directory {0} failed",
                    new NoSuchFileException(directory.getAbsolute()), directory);
        }
        try (DirectoryStream<java.nio.file.Path> stream = Files.newDirectoryStream(p)) {
            for(java.nio.file.Path n : stream) {
                if(null == n.getFileName()) {
                    continue;
                }
                try {
                    final PathAttributes attributes = feature.toAttributes(n);
                    final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class);
                    if(Files.isDirectory(n)) {
                        type.add(Path.Type.directory);
                    }
                    else {
                        type.add(Path.Type.file);
                    }
                    final Path file = new Path(directory, n.getFileName().toString(), type, attributes);
                    if(this.post(n, file)) {
                        paths.add(file);
                        listener.chunk(directory, paths);
                    }
                }
                catch(IOException e) {
                    log.warn(String.format("Failure reading attributes for %s", n));
                }
            }
        }
        catch(IOException ex) {
            throw new LocalExceptionMappingService().map("Listing directory {0} failed", ex, directory);
        }
        return paths;
    }
@Test(expected = NotfoundException.class)
    public void testListFile() throws Exception {
        final LocalSession session = new LocalSession(new Host(new LocalProtocol(), new LocalProtocol().getDefaultHostname()));
        session.open(new DisabledProxyFinder(), new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
        session.login(new DisabledLoginCallback(), new DisabledCancelCallback());
        final Path home = new LocalHomeFinderFeature().find();
        final LocalListService service = new LocalListService(session);
        service.list(new Path(home, "test", EnumSet.of(Path.Type.directory)), new DisabledListProgressListener());
    }