class SimpleFileSystemProvider implements FileSystemProvider {

    @Override
    public DirectoryStream<Path> newDirectoryStream(final Path dir,
                                                    final DirectoryStream.Filter<Path> filter)
            throws NotDirectoryException, IOException, SecurityException {
        checkNotNull("filter", filter);
        final Path[] content = getDirectoryContent(dir);
        return new DirectoryStream<Path>() {
            boolean isClosed = false;

            @Override
            public void close() throws IOException {
                if (isClosed) {
                    throw new IOException(STREAM_CLOSED);
                }
                isClosed = true;
            }

            @Override
            public Iterator<Path> iterator() {
                if (isClosed) {
                    throw new IOException(STREAM_CLOSED);
                }
                return new Iterator<Path>() {
                    public boolean atEof = false;
                    private int i = -1;
                    private Path nextEntry = null;

                    @Override
                    public boolean hasNext() {
                        if (isClosed) {
                            throw new IOException(STREAM_CLOSED);
                        }
                        if (nextEntry == null && !atEof) {
                            nextEntry = readNextEntry();
                        }
                        return nextEntry != null;
                    }

                    @Override
                    public Path next() {
                        final Path result;
                        if (isClosed) {
                            throw new IOException(STREAM_CLOSED);
                        }
                        if (nextEntry == null && !atEof) {
                            result = readNextEntry();
                        } else {
                            result = nextEntry;
                            nextEntry = null;
                        }
                        if (result == null) {
                            throw new NoSuchElementException();
                        }
                        return result;
                    }

                    private Path readNextEntry() {
                        if (atEof) {
                            return null;
                        }

                        Path result = null;
                        while (true) {
                            i++;
                            if (i >= content.length) {
                                atEof = true;
                                break;
                            }

                            final Path path = content[i];
                            if (filter.accept(path)) {
                                result = path;
                                break;
                            }
                        }

                        return result;
                    }

                    @Override
                    public void remove() {
                        throw new UnsupportedOperationException();
                    }
                };
            }
        };
    }

    public  SimpleFileSystemProvider();
    protected  SimpleFileSystemProvider(final File[] roots,
                                       final OSType osType);

}