@Deprecated public interface FileSystem
Provides native file system access for the built in SFTP server. Your server may implement the methods here to provide file system support. This is an optional feature since the server is preconfigured to use the VirtualFileSystem.
The SFTP protocol represents file names as strings. File names are assumed to use the slash ('/') character as a directory separator.
File names starting with a slash are "absolute", and are relative to the root of the file system. Names starting with any other character are relative to the user's default directory (home directory). It should noted that Windows style paths ARE NOT supported by the Virtual file system. Any path not starting with / are relative to the users home directory.
Implementations SHOULD interpret a path name component ".." as referring to the parent directory, and "." as referring to the current directory. If the implementation limits access to certain parts of the file system, it must be extra careful in parsing file names when enforcing such restrictions. There have been numerous reported security bugs where a ".." in a path name has allowed access outside the intended area.
An empty path name is valid, and it refers to the user's default directory (usually the user's home directory).
All file paths input and output from the provider must adhere to this format; conversion to a native file system is the responsibility of your own file system provider.
Modifier and Type | Field and Description |
---|---|
static String |
AUTHORIZED_KEYS_STORE
Deprecated.
|
static int |
OPEN_APPEND
Deprecated.
File open flag, forces all writes to append data at the end of the file.
|
static int |
OPEN_CREATE
Deprecated.
File open flag, if specified a new file will be created if one does not
already exist.
|
static int |
OPEN_EXCLUSIVE
Deprecated.
File open flag, causes an open request to fail if the named file already
exists.
|
static int |
OPEN_READ
Deprecated.
File open flag, opens the file for reading.
|
static int |
OPEN_TEXT
Deprecated.
Indicates the server should treat the file as text and convert
it to the canoncial newline convention in use.
|
static int |
OPEN_TRUNCATE
Deprecated.
File open flag, forces an existing file with the same name to be
truncated to zero length when creating a file by specifying OPEN_CREATE.
|
static int |
OPEN_WRITE
Deprecated.
File open flag, opens the file for writing.
|
static String |
SCP
Deprecated.
|
static String |
SFTP
Deprecated.
|
static String |
SHELL
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
closeFile(byte[] handle)
Deprecated.
Close an open file or directory.
|
void |
closeFilesystem()
Deprecated.
The filesystem instance is being closed and no further use of the
instance is required.
|
void |
createSymbolicLink(String link,
String target)
Deprecated.
Create a symbolic link.
|
boolean |
fileExists(String path)
Deprecated.
Determine whether a file exists and return the result
|
String |
getDefaultPath()
Deprecated.
Get the default path for the current session.
|
SftpFileAttributes |
getFileAttributes(byte[] handle)
Deprecated.
Get the attributes for a given file handle.
|
SftpFileAttributes |
getFileAttributes(String path)
Deprecated.
Get the attributes for a given file.
|
String |
getPathForHandle(byte[] handle)
Deprecated.
Return the path for a given handle.
|
String |
getRealPath(String path)
Deprecated.
Get the real path for a given path.
|
boolean |
makeDirectory(String path,
SftpFileAttributes attrs)
Deprecated.
Create a directory.
|
byte[] |
openDirectory(String path)
Deprecated.
Open a directory for reading and allocate an open file handle.
|
byte[] |
openFile(String path,
UnsignedInteger32 flags,
SftpFileAttributes attrs)
Deprecated.
Open a file for reading/writing and allocate an open file handle.
|
void |
populateEvent(Event event)
Deprecated.
Populate any extra fields in a file system event.
|
SftpFile[] |
readDirectory(byte[] handle)
Deprecated.
Read the contents of a directory.
|
int |
readFile(byte[] handle,
UnsignedInteger64 offset,
byte[] buffer,
int start,
int numBytesToRead)
Deprecated.
Read a block of data from an open file.
|
SftpFile |
readSymbolicLink(String path)
Deprecated.
Read the target location of a symbolic link.
|
void |
removeDirectory(String path)
Deprecated.
Remove an empty directory from the file system.
|
void |
removeFile(String path)
Deprecated.
Remove a file.
|
void |
renameFile(String oldpath,
String newpath)
Deprecated.
Rename a file.
|
void |
setFileAttributes(byte[] handle,
SftpFileAttributes attrs)
Deprecated.
Set the open files attributes
|
void |
setFileAttributes(String path,
SftpFileAttributes attrs)
Deprecated.
Set the files attributes.
|
void |
writeFile(byte[] handle,
UnsignedInteger64 offset,
byte[] data,
int off,
int len)
Deprecated.
Write a block of data to an open file.
|
static final int OPEN_READ
static final int OPEN_WRITE
static final int OPEN_APPEND
static final int OPEN_CREATE
static final int OPEN_TRUNCATE
static final int OPEN_EXCLUSIVE
static final int OPEN_TEXT
static final String AUTHORIZED_KEYS_STORE
static final String SFTP
static final String SCP
static final String SHELL
void closeFilesystem()
boolean fileExists(String path) throws IOException, PermissionDeniedException
path
- StringIOException
PermissionDeniedException
String getRealPath(String path) throws IOException, FileNotFoundException, PermissionDeniedException
path
- String the path to canonicalize.IOException
- if an unrecoverable error occurs.FileNotFoundException
- if the path cannot be found.PermissionDeniedException
String getPathForHandle(byte[] handle) throws InvalidHandleException, IOException
handle
- InvalidHandleException
IOException
boolean makeDirectory(String path, SftpFileAttributes attrs) throws PermissionDeniedException, FileNotFoundException, IOException
path
- String the absolute path to the new directory.attrs
- PermissionDeniedException
- if the user cannot perform this
operation.FileNotFoundException
- if the parent directory does not exist.IOException
SftpFileAttributes getFileAttributes(String path) throws IOException, FileNotFoundException, PermissionDeniedException
path
- String the absolute path to the fileIOException
FileNotFoundException
- if the file cannot be foundPermissionDeniedException
- if the user does not have access to
this fileSftpFileAttributes
SftpFileAttributes getFileAttributes(byte[] handle) throws IOException, InvalidHandleException, PermissionDeniedException
handle
- byte[]IOException
InvalidHandleException
PermissionDeniedException
byte[] openDirectory(String path) throws PermissionDeniedException, FileNotFoundException, IOException
path
- StringPermissionDeniedException
FileNotFoundException
IOException
SftpFile[] readDirectory(byte[] handle) throws InvalidHandleException, EOFException, IOException, PermissionDeniedException
Read 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.
handle
- byte[]InvalidHandleException
- the handle supplied is invalid.EOFException
- thrown once all the files contained with the
directory have been read.IOException
- an error occurredPermissionDeniedException
byte[] openFile(String path, UnsignedInteger32 flags, SftpFileAttributes attrs) throws PermissionDeniedException, FileNotFoundException, IOException
path
- Stringflags
- UnsignedInteger32attrs
- SftpFileAttributesPermissionDeniedException
FileNotFoundException
IOException
int readFile(byte[] handle, UnsignedInteger64 offset, byte[] buffer, int start, int numBytesToRead) throws InvalidHandleException, EOFException, IOException
handle
- byte[]offset
- UnsignedInteger64buffer
- byte[]start
- intnumBytesToRead
- intInvalidHandleException
EOFException
IOException
void writeFile(byte[] handle, UnsignedInteger64 offset, byte[] data, int off, int len) throws InvalidHandleException, IOException
handle
- byte[]offset
- UnsignedInteger64data
- byte[]off
- intlen
- intInvalidHandleException
IOException
void closeFile(byte[] handle) throws InvalidHandleException, IOException
handle
- byte[]InvalidHandleException
IOException
void removeFile(String path) throws PermissionDeniedException, IOException, FileNotFoundException
path
- StringPermissionDeniedException
IOException
FileNotFoundException
void renameFile(String oldpath, String newpath) throws PermissionDeniedException, FileNotFoundException, IOException
oldpath
- Stringnewpath
- StringPermissionDeniedException
FileNotFoundException
IOException
void removeDirectory(String path) throws PermissionDeniedException, FileNotFoundException, IOException
path
- StringPermissionDeniedException
FileNotFoundException
IOException
void setFileAttributes(String path, SftpFileAttributes attrs) throws PermissionDeniedException, IOException, FileNotFoundException
path
- Stringattrs
- SftpFileAttributesPermissionDeniedException
IOException
FileNotFoundException
void setFileAttributes(byte[] handle, SftpFileAttributes attrs) throws PermissionDeniedException, IOException, InvalidHandleException
handle
- byte[]attrs
- SftpFileAttributesPermissionDeniedException
IOException
InvalidHandleException
SftpFile readSymbolicLink(String path) throws UnsupportedFileOperationException, FileNotFoundException, IOException, PermissionDeniedException
path
- StringUnsupportedFileOperationException
FileNotFoundException
IOException
PermissionDeniedException
void createSymbolicLink(String link, String target) throws UnsupportedFileOperationException, FileNotFoundException, IOException, PermissionDeniedException
link
- Stringtarget
- StringUnsupportedFileOperationException
FileNotFoundException
IOException
PermissionDeniedException
String getDefaultPath() throws FileNotFoundException, IOException, PermissionDeniedException
FileNotFoundException
- if the users default path does not exist.PermissionDeniedException
IOException
void populateEvent(Event event)
event
- Copyright © 2024. All rights reserved.