@Test public void readMissing() throws Exception { try (FileData fileData = filesystemDirectory.getFileData("abc")) { assertNull(fileData); } }
@Override public FileData getFileData(String filename) throws IOException { Path path = directory.resolve(filename); if (!path.toFile().exists()) { return null; } if (Files.isDirectory(path)) { throw new IOException("Attempted to read file but it is a directory: " + filename); } FileChannel channel = FileChannel.open(path, READ, WRITE); return new FileChannelFileData(channel); }
FileBasedFilesystemDirectory implements FilesystemDirectory { @Override public FileData getFileData(String filename) throws IOException { Path path = directory.resolve(filename); if (!path.toFile().exists()) { return null; } if (Files.isDirectory(path)) { throw new IOException("Attempted to read file but it is a directory: " + filename); } FileChannel channel = FileChannel.open(path, READ, WRITE); return new FileChannelFileData(channel); } }
FileBasedFilesystemDirectory implements FilesystemDirectory { @Override public FileData getFileData(String filename) throws IOException { Path path = directory.resolve(filename); if (!path.toFile().exists()) { return null; } if (Files.isDirectory(path)) { throw new IOException("Attempted to read file but it is a directory: " + filename); } FileChannel channel = FileChannel.open(path, READ, WRITE); return new FileChannelFileData(channel); } FileBasedFilesystemDirectory(Path directory); }
FileBasedFilesystemDirectory implements FilesystemDirectory { @Override public FileData getFileData(String filename) throws IOException { Path path = directory.resolve(filename); if (!path.toFile().exists()) { return null; } if (Files.isDirectory(path)) { throw new IOException("Attempted to read file but it is a directory: " + filename); } FileChannel channel = FileChannel.open(path, READ, WRITE); return new FileChannelFileData(channel); } FileBasedFilesystemDirectory(Path directory); @Override DirectoryLock lock(); @Override FileData create(String filename, boolean canExist); @Override FileData getFileData(String filename); @Override void delete(String filename); @Override void backup(String filename); }
FileBasedFilesystemDirectory implements FilesystemDirectory { @Override public FileData getFileData(String filename) throws IOException { Path path = directory.resolve(filename); if (!path.toFile().exists()) { return null; } if (Files.isDirectory(path)) { throw new IOException("Attempted to read file but it is a directory: " + filename); } FileChannel channel = FileChannel.open(path, READ, WRITE); return new FileChannelFileData(channel); } FileBasedFilesystemDirectory(Path directory); @Override DirectoryLock lock(); @Override FileData create(String filename, boolean canExist); @Override FileData getFileData(String filename); @Override void delete(String filename); @Override void backup(String filename);  }