public class AbstractFileSystem<T extends AbstractFile,K extends FileSystemMount> extends Object implements FileSystem<K>
| Modifier and Type | Field and Description |
|---|---|
protected AbstractFileFactory<T,K> |
fileFactory |
protected Map<String,com.maverick.sshd.fs.AbstractFileSystem.OpenDirectory> |
openDirectories |
protected Map<String,com.maverick.sshd.fs.AbstractFileSystem.OpenFile> |
openFiles |
AUTHORIZED_KEYS_STORE, OPEN_APPEND, OPEN_CREATE, OPEN_EXCLUSIVE, OPEN_READ, OPEN_TRUNCATE, OPEN_WRITE, SCP, SFTP, SSH| Constructor and Description |
|---|
AbstractFileSystem(AbstractFileFactory<T,K> fileFactory,
Connection con,
String protocolInUse) |
| Modifier and Type | Method and Description |
|---|---|
void |
closeFile(byte[] handle)
Close an open file or directory.
|
boolean |
closeFile(byte[] handle,
boolean remove) |
void |
closeFilesystem()
The filesystem instance is being closed and no further use of the
instance is required.
|
void |
createSymbolicLink(String link,
String target)
Create a symbolic link.
|
boolean |
fileExists(String path)
Determine whether a file exists and return the result
|
String |
getDefaultPath()
Get the default path for the current session.
|
SftpFileAttributes |
getFileAttributes(byte[] handle)
Get the attributes for a given file handle.
|
SftpFileAttributes |
getFileAttributes(String path)
Get the attributes for a given file.
|
AbstractFileFactory<T,K> |
getFileFactory() |
MountManager<K> |
getMountManager() |
String |
getRealPath(String path)
Get the real path for a given path.
|
boolean |
makeDirectory(String path,
SftpFileAttributes attrs)
Create a directory.
|
byte[] |
openDirectory(String path)
Open a directory for reading and allocate an open file handle.
|
byte[] |
openFile(String path,
com.maverick.util.UnsignedInteger32 flags,
SftpFileAttributes attrs)
Open a file for reading/writing and allocate an open file handle.
|
SftpFile[] |
readDirectory(byte[] handle)
Read the contents of a directory.
|
int |
readFile(byte[] handle,
com.maverick.util.UnsignedInteger64 offset,
byte[] buf,
int start,
int numBytesToRead)
Read a block of data from an open file.
|
SftpFile |
readSymbolicLink(String path)
Read the target location of a symbolic link.
|
void |
removeDirectory(String path)
Remove an empty directory from the file system.
|
void |
removeFile(String path)
Remove a file.
|
void |
renameFile(String oldpath,
String newpath)
Rename a file.
|
AbstractFile |
resolveFile(String path) |
void |
setFileAttributes(byte[] handle,
SftpFileAttributes attrs)
Set the open files attributes
|
void |
setFileAttributes(String path,
SftpFileAttributes attrs)
Set the files attributes.
|
boolean |
supportsMounting() |
void |
writeFile(byte[] handle,
com.maverick.util.UnsignedInteger64 offset,
byte[] data,
int off,
int len)
Write a block of data to an open file.
|
protected Map<String,com.maverick.sshd.fs.AbstractFileSystem.OpenDirectory> openDirectories
protected AbstractFileFactory<T extends AbstractFile,K extends FileSystemMount> fileFactory
public AbstractFileSystem(AbstractFileFactory<T,K> fileFactory, Connection con, String protocolInUse)
public AbstractFile resolveFile(String path) throws PermissionDeniedException, IOException
PermissionDeniedExceptionIOExceptionpublic void closeFilesystem()
FileSystemcloseFilesystem in interface FileSystem<K extends FileSystemMount>public boolean makeDirectory(String path, SftpFileAttributes attrs) throws PermissionDeniedException, FileNotFoundException, IOException
FileSystemmakeDirectory in interface FileSystem<K extends FileSystemMount>path - String the absolute path to the new directory.PermissionDeniedException - if the user cannot perform this
operation.FileNotFoundException - if the parent directory does not exist.IOExceptionpublic SftpFileAttributes getFileAttributes(byte[] handle) throws IOException, InvalidHandleException, PermissionDeniedException
FileSystemgetFileAttributes in interface FileSystem<K extends FileSystemMount>handle - byte[]IOExceptionInvalidHandleExceptionPermissionDeniedExceptionpublic SftpFileAttributes getFileAttributes(String path) throws IOException, FileNotFoundException, PermissionDeniedException
FileSystemgetFileAttributes in interface FileSystem<K extends FileSystemMount>path - String the absolute path to the fileIOExceptionFileNotFoundException - if the file cannot be foundPermissionDeniedException - if the user does not have access to
this filecom.maverick.sftp.SftpFileAttributespublic byte[] openDirectory(String path) throws PermissionDeniedException, FileNotFoundException, IOException
FileSystemopenDirectory in interface FileSystem<K extends FileSystemMount>path - StringPermissionDeniedExceptionFileNotFoundExceptionIOExceptionpublic SftpFile[] readDirectory(byte[] handle) throws InvalidHandleException, EOFException, IOException, PermissionDeniedException
FileSystemRead the contents of a directory. Each call to this method should return one or more file objects with full file attributes for each file. The client will call this method repeatedly until an EOFException is thrown indicating that there are no more files to read from the directory. If there are no files to list then the EOFException should be thrown upon first call.
IMPORTANT: Each SftpFile object should be initialized with the relative path of the file AND NOT the absolute path.
readDirectory in interface FileSystem<K extends FileSystemMount>handle - byte[]InvalidHandleException - the handle supplied is invalid.EOFException - thrown once all the files contained with the
directory have been read.IOException - an error occurredPermissionDeniedExceptionpublic byte[] openFile(String path, com.maverick.util.UnsignedInteger32 flags, SftpFileAttributes attrs) throws PermissionDeniedException, FileNotFoundException, IOException
FileSystemopenFile in interface FileSystem<K extends FileSystemMount>path - Stringflags - UnsignedInteger32attrs - SftpFileAttributesPermissionDeniedExceptionFileNotFoundExceptionIOExceptionpublic int readFile(byte[] handle,
com.maverick.util.UnsignedInteger64 offset,
byte[] buf,
int start,
int numBytesToRead)
throws InvalidHandleException,
EOFException,
IOException
FileSystemreadFile in interface FileSystem<K extends FileSystemMount>handle - byte[]offset - UnsignedInteger64buf - byte[]start - intnumBytesToRead - intInvalidHandleExceptionEOFExceptionIOExceptionpublic void writeFile(byte[] handle,
com.maverick.util.UnsignedInteger64 offset,
byte[] data,
int off,
int len)
throws InvalidHandleException,
IOException
FileSystemwriteFile in interface FileSystem<K extends FileSystemMount>handle - byte[]offset - UnsignedInteger64data - byte[]off - intlen - intInvalidHandleExceptionIOExceptionpublic void closeFile(byte[] handle)
throws InvalidHandleException,
IOException
FileSystemcloseFile in interface FileSystem<K extends FileSystemMount>handle - byte[]InvalidHandleExceptionIOExceptionpublic boolean closeFile(byte[] handle,
boolean remove)
throws InvalidHandleException,
IOException
InvalidHandleExceptionIOExceptionpublic void removeFile(String path) throws PermissionDeniedException, IOException, FileNotFoundException
FileSystemremoveFile in interface FileSystem<K extends FileSystemMount>path - StringPermissionDeniedExceptionIOExceptionFileNotFoundExceptionpublic void renameFile(String oldpath, String newpath) throws PermissionDeniedException, FileNotFoundException, IOException
FileSystemrenameFile in interface FileSystem<K extends FileSystemMount>oldpath - Stringnewpath - StringPermissionDeniedExceptionFileNotFoundExceptionIOExceptionpublic String getDefaultPath() throws IOException, PermissionDeniedException
FileSystemgetDefaultPath in interface FileSystem<K extends FileSystemMount>FileNotFoundException - if the users default path does not exist.IOExceptionPermissionDeniedExceptionpublic void removeDirectory(String path) throws PermissionDeniedException, FileNotFoundException, IOException
FileSystemremoveDirectory in interface FileSystem<K extends FileSystemMount>path - StringPermissionDeniedExceptionFileNotFoundExceptionIOExceptionpublic void setFileAttributes(String path, SftpFileAttributes attrs) throws PermissionDeniedException, IOException, FileNotFoundException
FileSystemsetFileAttributes in interface FileSystem<K extends FileSystemMount>path - Stringattrs - SftpFileAttributesPermissionDeniedExceptionIOExceptionFileNotFoundExceptionpublic void setFileAttributes(byte[] handle,
SftpFileAttributes attrs)
throws PermissionDeniedException,
IOException,
InvalidHandleException
FileSystemsetFileAttributes in interface FileSystem<K extends FileSystemMount>handle - byte[]attrs - SftpFileAttributesPermissionDeniedExceptionIOExceptionInvalidHandleExceptionpublic SftpFile readSymbolicLink(String path) throws UnsupportedFileOperationException, FileNotFoundException, IOException, PermissionDeniedException
FileSystemreadSymbolicLink in interface FileSystem<K extends FileSystemMount>path - StringUnsupportedFileOperationExceptionFileNotFoundExceptionIOExceptionPermissionDeniedExceptionpublic void createSymbolicLink(String link, String target) throws UnsupportedFileOperationException, FileNotFoundException, IOException, PermissionDeniedException
FileSystemcreateSymbolicLink in interface FileSystem<K extends FileSystemMount>link - Stringtarget - StringUnsupportedFileOperationExceptionFileNotFoundExceptionIOExceptionPermissionDeniedExceptionpublic boolean fileExists(String path) throws IOException, PermissionDeniedException
FileSystemfileExists in interface FileSystem<K extends FileSystemMount>path - StringIOExceptionPermissionDeniedExceptionpublic String getRealPath(String path) throws IOException, FileNotFoundException, PermissionDeniedException
FileSystemgetRealPath in interface FileSystem<K extends FileSystemMount>path - String the path to canonicalize.IOException - if an unrecoverable error occurs.FileNotFoundException - if the path cannot be found.PermissionDeniedExceptionpublic boolean supportsMounting()
supportsMounting in interface FileSystem<K extends FileSystemMount>public MountManager<K> getMountManager() throws IOException, PermissionDeniedException
getMountManager in interface FileSystem<K extends FileSystemMount>IOExceptionPermissionDeniedExceptionpublic AbstractFileFactory<T,K> getFileFactory()
Copyright © 2012. All Rights Reserved.