Package org.apache.sshd.common.file.root
Class RootedFileSystemProvider
- java.lang.Object
-
- java.nio.file.spi.FileSystemProvider
-
- org.apache.sshd.common.file.root.RootedFileSystemProvider
-
public class RootedFileSystemProvider extends java.nio.file.spi.FileSystemProviderFile system provider which provides a rooted file system. The file system only gives access to files under the root directory.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.nio.file.Path,RootedFileSystem>fileSystemsprotected org.slf4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description RootedFileSystemProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckAccess(java.nio.file.Path path, java.nio.file.AccessMode... modes)voidcopy(java.nio.file.Path source, java.nio.file.Path target, java.nio.file.CopyOption... options)voidcreateDirectory(java.nio.file.Path dir, java.nio.file.attribute.FileAttribute<?>... attrs)voidcreateLink(java.nio.file.Path link, java.nio.file.Path existing)voidcreateSymbolicLink(java.nio.file.Path link, java.nio.file.Path target, java.nio.file.attribute.FileAttribute<?>... attrs)voiddelete(java.nio.file.Path path)booleandeleteIfExists(java.nio.file.Path path)private static java.nio.file.PathensureDirectory(java.nio.file.Path path)private java.lang.StringfixExceptionFileName(java.nio.file.Path root, java.nio.file.Path rootedPath, java.lang.String fileName)<V extends java.nio.file.attribute.FileAttributeView>
VgetFileAttributeView(java.nio.file.Path path, java.lang.Class<V> type, java.nio.file.LinkOption... options)java.nio.file.FileStoregetFileStore(java.nio.file.Path path)java.nio.file.FileSystemgetFileSystem(java.net.URI uri)protected RootedFileSystemgetFileSystem(java.nio.file.Path path)java.nio.file.PathgetPath(java.net.URI uri)java.lang.StringgetScheme()booleanisHidden(java.nio.file.Path path)booleanisSameFile(java.nio.file.Path path, java.nio.file.Path path2)voidmove(java.nio.file.Path source, java.nio.file.Path target, java.nio.file.CopyOption... options)java.nio.channels.AsynchronousFileChannelnewAsynchronousFileChannel(java.nio.file.Path path, java.util.Set<? extends java.nio.file.OpenOption> options, java.util.concurrent.ExecutorService executor, java.nio.file.attribute.FileAttribute<?>... attrs)java.nio.channels.SeekableByteChannelnewByteChannel(java.nio.file.Path path, java.util.Set<? extends java.nio.file.OpenOption> options, java.nio.file.attribute.FileAttribute<?>... attrs)java.nio.file.DirectoryStream<java.nio.file.Path>newDirectoryStream(java.nio.file.Path dir, java.nio.file.DirectoryStream.Filter<? super java.nio.file.Path> filter)java.nio.channels.FileChannelnewFileChannel(java.nio.file.Path path, java.util.Set<? extends java.nio.file.OpenOption> options, java.nio.file.attribute.FileAttribute<?>... attrs)protected java.nio.file.FileSystemnewFileSystem(java.lang.Object src, java.nio.file.Path path, java.util.Map<java.lang.String,?> env)java.nio.file.FileSystemnewFileSystem(java.net.URI uri, java.util.Map<java.lang.String,?> env)java.nio.file.FileSystemnewFileSystem(java.nio.file.Path path, java.util.Map<java.lang.String,?> env)java.io.InputStreamnewInputStream(java.nio.file.Path path, java.nio.file.OpenOption... options)java.io.OutputStreamnewOutputStream(java.nio.file.Path path, java.nio.file.OpenOption... options)protected java.nio.file.spi.FileSystemProviderprovider(java.nio.file.Path path)<A extends java.nio.file.attribute.BasicFileAttributes>
AreadAttributes(java.nio.file.Path path, java.lang.Class<A> type, java.nio.file.LinkOption... options)java.util.Map<java.lang.String,java.lang.Object>readAttributes(java.nio.file.Path path, java.lang.String attributes, java.nio.file.LinkOption... options)java.nio.file.PathreadSymbolicLink(java.nio.file.Path link)protected java.nio.file.PathresolveLocalPath(RootedPath path)protected java.nio.file.DirectoryStream<java.nio.file.Path>root(RootedFileSystem rfs, java.nio.file.DirectoryStream<java.nio.file.Path> ds)protected java.nio.file.Pathroot(RootedFileSystem rfs, java.nio.file.Path nat)voidsetAttribute(java.nio.file.Path path, java.lang.String attribute, java.lang.Object value, java.nio.file.LinkOption... options)private java.io.IOExceptiontranslateIoException(java.io.IOException ex, java.nio.file.Path rootedPath)protected java.nio.file.Pathunroot(java.nio.file.Path path)protected java.nio.file.PathuriToPath(java.net.URI uri)
-
-
-
Field Detail
-
log
protected final org.slf4j.Logger log
-
fileSystems
private final java.util.Map<java.nio.file.Path,RootedFileSystem> fileSystems
-
-
Method Detail
-
getScheme
public java.lang.String getScheme()
- Specified by:
getSchemein classjava.nio.file.spi.FileSystemProvider
-
newFileSystem
public java.nio.file.FileSystem newFileSystem(java.net.URI uri, java.util.Map<java.lang.String,?> env) throws java.io.IOException- Specified by:
newFileSystemin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
getFileSystem
public java.nio.file.FileSystem getFileSystem(java.net.URI uri)
- Specified by:
getFileSystemin classjava.nio.file.spi.FileSystemProvider
-
newFileSystem
public java.nio.file.FileSystem newFileSystem(java.nio.file.Path path, java.util.Map<java.lang.String,?> env) throws java.io.IOException- Overrides:
newFileSystemin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
newFileSystem
protected java.nio.file.FileSystem newFileSystem(java.lang.Object src, java.nio.file.Path path, java.util.Map<java.lang.String,?> env) throws java.io.IOException- Throws:
java.io.IOException
-
uriToPath
protected java.nio.file.Path uriToPath(java.net.URI uri)
-
ensureDirectory
private static java.nio.file.Path ensureDirectory(java.nio.file.Path path)
-
getPath
public java.nio.file.Path getPath(java.net.URI uri)
- Specified by:
getPathin classjava.nio.file.spi.FileSystemProvider
-
newInputStream
public java.io.InputStream newInputStream(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException- Overrides:
newInputStreamin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
newOutputStream
public java.io.OutputStream newOutputStream(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException- Overrides:
newOutputStreamin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
newFileChannel
public java.nio.channels.FileChannel newFileChannel(java.nio.file.Path path, java.util.Set<? extends java.nio.file.OpenOption> options, java.nio.file.attribute.FileAttribute<?>... attrs) throws java.io.IOException- Overrides:
newFileChannelin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
newAsynchronousFileChannel
public java.nio.channels.AsynchronousFileChannel newAsynchronousFileChannel(java.nio.file.Path path, java.util.Set<? extends java.nio.file.OpenOption> options, java.util.concurrent.ExecutorService executor, java.nio.file.attribute.FileAttribute<?>... attrs) throws java.io.IOException- Overrides:
newAsynchronousFileChannelin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
newByteChannel
public java.nio.channels.SeekableByteChannel newByteChannel(java.nio.file.Path path, java.util.Set<? extends java.nio.file.OpenOption> options, java.nio.file.attribute.FileAttribute<?>... attrs) throws java.io.IOException- Specified by:
newByteChannelin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
newDirectoryStream
public java.nio.file.DirectoryStream<java.nio.file.Path> newDirectoryStream(java.nio.file.Path dir, java.nio.file.DirectoryStream.Filter<? super java.nio.file.Path> filter) throws java.io.IOException- Specified by:
newDirectoryStreamin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
root
protected java.nio.file.DirectoryStream<java.nio.file.Path> root(RootedFileSystem rfs, java.nio.file.DirectoryStream<java.nio.file.Path> ds)
-
createDirectory
public void createDirectory(java.nio.file.Path dir, java.nio.file.attribute.FileAttribute<?>... attrs) throws java.io.IOException- Specified by:
createDirectoryin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
createSymbolicLink
public void createSymbolicLink(java.nio.file.Path link, java.nio.file.Path target, java.nio.file.attribute.FileAttribute<?>... attrs) throws java.io.IOException- Overrides:
createSymbolicLinkin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
createLink
public void createLink(java.nio.file.Path link, java.nio.file.Path existing) throws java.io.IOException- Overrides:
createLinkin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
delete
public void delete(java.nio.file.Path path) throws java.io.IOException- Specified by:
deletein classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
deleteIfExists
public boolean deleteIfExists(java.nio.file.Path path) throws java.io.IOException- Overrides:
deleteIfExistsin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
readSymbolicLink
public java.nio.file.Path readSymbolicLink(java.nio.file.Path link) throws java.io.IOException- Overrides:
readSymbolicLinkin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
copy
public void copy(java.nio.file.Path source, java.nio.file.Path target, java.nio.file.CopyOption... options) throws java.io.IOException- Specified by:
copyin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
move
public void move(java.nio.file.Path source, java.nio.file.Path target, java.nio.file.CopyOption... options) throws java.io.IOException- Specified by:
movein classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
isSameFile
public boolean isSameFile(java.nio.file.Path path, java.nio.file.Path path2) throws java.io.IOException- Specified by:
isSameFilein classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
isHidden
public boolean isHidden(java.nio.file.Path path) throws java.io.IOException- Specified by:
isHiddenin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
getFileStore
public java.nio.file.FileStore getFileStore(java.nio.file.Path path) throws java.io.IOException- Specified by:
getFileStorein classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
getFileSystem
protected RootedFileSystem getFileSystem(java.nio.file.Path path) throws java.nio.file.FileSystemNotFoundException
- Throws:
java.nio.file.FileSystemNotFoundException
-
checkAccess
public void checkAccess(java.nio.file.Path path, java.nio.file.AccessMode... modes) throws java.io.IOException- Specified by:
checkAccessin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
getFileAttributeView
public <V extends java.nio.file.attribute.FileAttributeView> V getFileAttributeView(java.nio.file.Path path, java.lang.Class<V> type, java.nio.file.LinkOption... options)- Specified by:
getFileAttributeViewin classjava.nio.file.spi.FileSystemProvider
-
readAttributes
public <A extends java.nio.file.attribute.BasicFileAttributes> A readAttributes(java.nio.file.Path path, java.lang.Class<A> type, java.nio.file.LinkOption... options) throws java.io.IOException- Specified by:
readAttributesin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
readAttributes
public java.util.Map<java.lang.String,java.lang.Object> readAttributes(java.nio.file.Path path, java.lang.String attributes, java.nio.file.LinkOption... options) throws java.io.IOException- Specified by:
readAttributesin classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
setAttribute
public void setAttribute(java.nio.file.Path path, java.lang.String attribute, java.lang.Object value, java.nio.file.LinkOption... options) throws java.io.IOException- Specified by:
setAttributein classjava.nio.file.spi.FileSystemProvider- Throws:
java.io.IOException
-
provider
protected java.nio.file.spi.FileSystemProvider provider(java.nio.file.Path path)
-
root
protected java.nio.file.Path root(RootedFileSystem rfs, java.nio.file.Path nat)
-
unroot
protected java.nio.file.Path unroot(java.nio.file.Path path)
- Parameters:
path- The original (rooted)Path- Returns:
- The actual absolute local
Pathrepresented by the rooted one - Throws:
java.lang.IllegalArgumentException- ifnullpath argumentjava.nio.file.ProviderMismatchException- if not aRootedPath- See Also:
resolveLocalPath(RootedPath)
-
resolveLocalPath
protected java.nio.file.Path resolveLocalPath(RootedPath path)
- Parameters:
path- The originalRootedPath- nevernull- Returns:
- The actual absolute local
Pathrepresented by the rooted one - Throws:
java.nio.file.InvalidPathException- If the resolved path is not a proper sub-path of the rooted file system
-
translateIoException
private java.io.IOException translateIoException(java.io.IOException ex, java.nio.file.Path rootedPath)
-
fixExceptionFileName
private java.lang.String fixExceptionFileName(java.nio.file.Path root, java.nio.file.Path rootedPath, java.lang.String fileName)
-
-