@Test public void testReadDir() throws Exception { Path foo = mockPath("foo"); Path bar = mockPath("bar"); mockDirectoryStream(mirrorRoot, foo, bar); DirectoryFiller filler = mock(DirectoryFiller.class); int result = fs.readdir("/", filler); assertThat(result).isEqualTo(SUCCESS); verify(fileSystem.provider()).newDirectoryStream(eq(mirrorRoot), any()); verify(filler).add(".", mirrorRoot); verify(filler).add("..", mirrorRoot); verify(filler).add("foo", foo); verify(filler).add("bar", bar); verifyNoMoreInteractions(filler); }
@Override public int readdir(String path, DirectoryFiller filler) { Path realPath = readdirInitial(path, filler); return tryCatch.apply(() -> { try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(realPath)) { for (Path entry : directoryStream) { if (!add(filler, entry)) { return SUCCESS; } } } return SUCCESS; }); }
MirrorFs implements se.tfiskgul.mux2fs.fs.base.FileSystem { @Override public int readdir(String path, DirectoryFiller filler) { Path realPath = readdirInitial(path, filler); return tryCatch.apply(() -> { try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(realPath)) { for (Path entry : directoryStream) { if (!add(filler, entry)) { return SUCCESS; } } } return SUCCESS; }); } }
MirrorFs implements se.tfiskgul.mux2fs.fs.base.FileSystem { @Override public int readdir(String path, DirectoryFiller filler) { Path realPath = readdirInitial(path, filler); return tryCatch.apply(() -> { try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(realPath)) { for (Path entry : directoryStream) { if (!add(filler, entry)) { return SUCCESS; } } } return SUCCESS; }); } MirrorFs(Path mirroredPath); @VisibleForTesting protected  MirrorFs(Path mirroredPath, FileChannelCloser fileChannelCloser); }
MirrorFs implements se.tfiskgul.mux2fs.fs.base.FileSystem { @Override public int readdir(String path, DirectoryFiller filler) { Path realPath = readdirInitial(path, filler); return tryCatch.apply(() -> { try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(realPath)) { for (Path entry : directoryStream) { if (!add(filler, entry)) { return SUCCESS; } } } return SUCCESS; }); } MirrorFs(Path mirroredPath); @VisibleForTesting protected  MirrorFs(Path mirroredPath, FileChannelCloser fileChannelCloser); @Override String getFSName(); @Override int getattr(String path, StatFiller stat); @Override int readdir(String path, DirectoryFiller filler); @Override int readLink(String path, Consumer<String> buf, int size); @Override int open(String path, FileHandleFiller filler); @Override int read(String path, Consumer<byte[]> buf, int size, long offset, int fileHandle); @Override int release(String path, int fileHandle); @Override void destroy(); }
MirrorFs implements se.tfiskgul.mux2fs.fs.base.FileSystem { @Override public int readdir(String path, DirectoryFiller filler) { Path realPath = readdirInitial(path, filler); return tryCatch.apply(() -> { try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(realPath)) { for (Path entry : directoryStream) { if (!add(filler, entry)) { return SUCCESS; } } } return SUCCESS; }); } MirrorFs(Path mirroredPath); @VisibleForTesting protected  MirrorFs(Path mirroredPath, FileChannelCloser fileChannelCloser); @Override String getFSName(); @Override int getattr(String path, StatFiller stat); @Override int readdir(String path, DirectoryFiller filler); @Override int readLink(String path, Consumer<String> buf, int size); @Override int open(String path, FileHandleFiller filler); @Override int read(String path, Consumer<byte[]> buf, int size, long offset, int fileHandle); @Override int release(String path, int fileHandle); @Override void destroy();  }