Skip to content

Instantly share code, notes, and snippets.

@forax
Created April 22, 2017 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forax/615828b41c33eccda33afdf2eba1db87 to your computer and use it in GitHub Desktop.
Save forax/615828b41c33eccda33afdf2eba1db87 to your computer and use it in GitHub Desktop.
A dummy FileSystemlProvider
package filesystem_provider;
import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.WatchService;
import java.nio.file.attribute.UserPrincipalLookupService;
import java.nio.file.spi.FileSystemProvider;
import java.util.Objects;
import java.util.Set;
public class DefaultFileSystem extends FileSystem {
private final FileSystem delegate;
private final DefaultFileSystemProvider fileSystemProvider;
DefaultFileSystem(DefaultFileSystemProvider fileSystemProvider,FileSystem delegate) {
this.fileSystemProvider = Objects.requireNonNull(fileSystemProvider);
this.delegate = Objects.requireNonNull(delegate);
}
@Override
public FileSystemProvider provider() {
return fileSystemProvider;
}
@Override
public Path getPath(String first, String... more) {
return delegate.getPath(first, more);
}
@Override
public void close() throws IOException {
delegate.close();
}
@Override
public Iterable<FileStore> getFileStores() {
return delegate.getFileStores();
}
@Override
public PathMatcher getPathMatcher(String syntaxAndPattern) {
return delegate.getPathMatcher(syntaxAndPattern);
}
@Override
public Iterable<Path> getRootDirectories() {
return delegate.getRootDirectories();
}
@Override
public String getSeparator() {
return delegate.getSeparator();
}
@Override
public UserPrincipalLookupService getUserPrincipalLookupService() {
return delegate.getUserPrincipalLookupService();
}
@Override
public boolean isOpen() {
return delegate.isOpen();
}
@Override
public boolean isReadOnly() {
return delegate.isReadOnly();
}
@Override
public WatchService newWatchService() throws IOException {
return delegate.newWatchService();
}
@Override
public Set<String> supportedFileAttributeViews() {
return delegate.supportedFileAttributeViews();
}
}
package filesystem_provider;
import java.io.IOException;
import java.net.URI;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.AccessMode;
import java.nio.file.CopyOption;
import java.nio.file.DirectoryStream;
import java.nio.file.DirectoryStream.Filter;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.LinkOption;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.spi.FileSystemProvider;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
public class DefaultFileSystemProvider extends FileSystemProvider {
private final FileSystemProvider delegate;
public DefaultFileSystemProvider(FileSystemProvider delegate) {
this.delegate = Objects.requireNonNull(delegate);
}
@Override
public Path getPath(URI uri) {
return delegate.getPath(uri);
}
@Override
public FileSystem getFileSystem(URI uri) {
return delegate.getFileSystem(uri);
}
@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {
return delegate.newFileSystem(uri, env);
}
@Override
public void checkAccess(Path path, AccessMode... modes) throws IOException {
delegate.checkAccess(path, modes);
}
@Override
public void copy(Path source, Path target, CopyOption... options) throws IOException {
delegate.copy(source, target, options);
}
@Override
public void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException {
delegate.createDirectory(dir, attrs);
}
@Override
public void delete(Path path) throws IOException {
delegate.delete(path);
}
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
return delegate.getFileAttributeView(path, type, options);
}
@Override
public FileStore getFileStore(Path path) throws IOException {
return delegate.getFileStore(path);
}
@Override
public String getScheme() {
return delegate.getScheme();
}
@Override
public boolean isHidden(Path path) throws IOException {
return delegate.isHidden(path);
}
@Override
public boolean isSameFile(Path path, Path path2) throws IOException {
return delegate.isSameFile(path, path2);
}
@Override
public void move(Path source, Path target, CopyOption... options) throws IOException {
delegate.move(source, target, options);
}
@Override
public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
return delegate.newByteChannel(path, options, attrs);
}
@Override
public DirectoryStream<Path> newDirectoryStream(Path dir, Filter<? super Path> filter) throws IOException {
return delegate.newDirectoryStream(dir, filter);
}
@Override
public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> attributes, LinkOption... options) throws IOException {
return delegate.readAttributes(path, attributes, options);
}
@Override
public Map<String, Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException {
return delegate.readAttributes(path, attributes, options);
}
@Override
public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException {
delegate.setAttribute(path, attribute, value, options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment