org.apache.sshd.server
Interface SshFile

All Known Implementing Classes:
NativeSshFile

public interface SshFile

This is the file abstraction used by the server.

Author:
Apache MINA Project

Method Summary
 boolean create()
          Create the file.
 InputStream createInputStream(long offset)
          Create input stream for reading.
 OutputStream createOutputStream(long offset)
          Create output stream for writing.
 boolean delete()
          Delete file.
 boolean doesExist()
          Does this file exists?
 String getAbsolutePath()
          Get the full path from the base directory of the FileSystemView.
 long getLastModified()
          Get last modified time in UTC.
 String getName()
          Get the file name of the file
 SshFile getParentFile()
          Get the immediate parent.
 long getSize()
          Get file size.
 void handleClose()
          Handle post-handle-close functionality.
 boolean isDirectory()
          Is it a directory?
 boolean isExecutable()
          Has exec permission?
 boolean isFile()
          Is it a file?
 boolean isReadable()
          Has read permission?
 boolean isRemovable()
          Has delete permission?
 boolean isWritable()
          Has write permission?
 List<SshFile> listSshFiles()
          List file objects.
 boolean mkdir()
          Create directory.
 boolean move(SshFile destination)
          Move file.
 boolean setLastModified(long time)
          Set the last modified time stamp of a file
 void truncate()
          Truncate the file to length 0.
 

Method Detail

getAbsolutePath

String getAbsolutePath()
Get the full path from the base directory of the FileSystemView.

Returns:
a path where the path separator is '/' (even if the operating system uses another character as path separator).

getName

String getName()
Get the file name of the file

Returns:
the last part of the file path (the part after the last '/').

isDirectory

boolean isDirectory()
Is it a directory?

Returns:
true if the SshFile is a directory

isFile

boolean isFile()
Is it a file?

Returns:
true if the SshFile is a file, false if it is a directory

doesExist

boolean doesExist()
Does this file exists?

Returns:
true if the SshFile exists

isReadable

boolean isReadable()
Has read permission?

Returns:
true if the SshFile is readable by the user

isWritable

boolean isWritable()
Has write permission?

Returns:
true if the SshFile is writable by the user

isExecutable

boolean isExecutable()
Has exec permission?

Returns:
true if the SshFile is executable by the user

isRemovable

boolean isRemovable()
Has delete permission?

Returns:
true if the SshFile is removable by the user

getParentFile

SshFile getParentFile()
Get the immediate parent. Returns the root directory if the current file is the root.

Returns:

getLastModified

long getLastModified()
Get last modified time in UTC.

Returns:
The timestamp of the last modified time for the SshFile

setLastModified

boolean setLastModified(long time)
Set the last modified time stamp of a file

Parameters:
time - The last modified time, in milliseconds since the epoch. See File.setLastModified(long).

getSize

long getSize()
Get file size.

Returns:
The size of the SshFile in bytes

mkdir

boolean mkdir()
Create directory.

Returns:
true if the operation was successful

delete

boolean delete()
Delete file.

Returns:
true if the operation was successful

create

boolean create()
               throws IOException
Create the file.

Returns:
true if the file has been created and false if it already exist
Throws:
IOException - if something wrong happen

truncate

void truncate()
              throws IOException
Truncate the file to length 0.

Throws:
IOException - if something wrong happen

move

boolean move(SshFile destination)
Move file.

Parameters:
destination - The target SshFile to move the current SshFile to
Returns:
true if the operation was successful

listSshFiles

List<SshFile> listSshFiles()
List file objects. If not a directory or does not exist, null will be returned. Files must be returned in alphabetical order. List must be immutable.

Returns:
The List of SshFiles

createOutputStream

OutputStream createOutputStream(long offset)
                                throws IOException
Create output stream for writing.

Parameters:
offset - The number of bytes at where to start writing. If the file is not random accessible, any offset other than zero will throw an exception.
Returns:
An OutputStream used to write to the SshFile
Throws:
IOException

createInputStream

InputStream createInputStream(long offset)
                              throws IOException
Create input stream for reading.

Parameters:
offset - The number of bytes of where to start reading. If the file is not random accessible, any offset other than zero will throw an exception.
Returns:
An InputStream used to read the SshFile
Throws:
IOException

handleClose

void handleClose()
                 throws IOException
Handle post-handle-close functionality.

Throws:
IOException


Copyright © 2008-2012 Apache Software Foundation. All Rights Reserved.