com.maverick.sftp
Class SftpFile

java.lang.Object
  extended bycom.maverick.sftp.SftpFile

public class SftpFile
extends java.lang.Object

Represents an SFTP file object.

Author:
Lee David Painter

Constructor Summary
SftpFile(java.lang.String path, SftpFileAttributes attrs)
          Creates a new SftpFile object.
 
Method Summary
 boolean canRead()
          Determine whether the user has read access to the file.
 boolean canWrite()
          Determine whether the user has write access to the file.
 void close()
          Close the file.
 void delete()
          Delete this file/directory from the remote server.
 boolean equals(java.lang.Object obj)
          Compares the Object to this instance and returns true if they point to the same file.
 java.lang.String getAbsolutePath()
          Get the absolute path
 SftpFileAttributes getAttributes()
          Get the files attributes.
 java.lang.String getFilename()
          Get the filename.
 byte[] getHandle()
          Get the open file handle
 SftpFile getParent()
          Get the parent of the current file.
 SftpSubsystemChannel getSFTPChannel()
          Get the SFTP subsystem channel that created this file object.
 int hashCode()
           
 boolean isBlock()
          Determine whether the file is pointing to a block special file.
 boolean isCharacter()
          Determine whether the file is pointing to a character mode device.
 boolean isDirectory()
          Determine whether the file object is pointing to a directory.
 boolean isFifo()
          Determine whether the file is pointing to a pipe.
 boolean isFile()
          Determine whether the file object is pointing to a file.
 boolean isLink()
          Determine whether the file object is a symbolic link.
 boolean isOpen()
          Determine whether the file is open.
 boolean isSocket()
          Determine whether the file is pointing to a socket.
 void rename(java.lang.String newFilename)
          Rename a file on the remote server.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SftpFile

public SftpFile(java.lang.String path,
                SftpFileAttributes attrs)
Creates a new SftpFile object.

Parameters:
attrs -
Method Detail

getParent

public SftpFile getParent()
                   throws SshException,
                          SftpStatusException
Get the parent of the current file. This method determines the correct path of the parent file; if no parent exists (i.e. the current file is the root of the filesystem) then this method returns a null value.

Returns:
Throws:
SshException
SftpStatusException

toString

public java.lang.String toString()

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object obj)
Compares the Object to this instance and returns true if they point to the same file. If they point to the same file but have open file handles, the handles are also used to determine the equality. Therefore two seperate instances both pointing to the same file will return true, unless one or both have an open file handle in which case it will only return true if the file handles also match.

Parameters:
obj -
Returns:

delete

public void delete()
            throws SftpStatusException,
                   SshException
Delete this file/directory from the remote server.

Throws:
SshException
SftpStatusException

rename

public void rename(java.lang.String newFilename)
            throws SftpStatusException,
                   SshException
Rename a file on the remote server.

Parameters:
newFilename -
Throws:
SshException
SftpStatusException

canWrite

public boolean canWrite()
                 throws SftpStatusException,
                        SshException
Determine whether the user has write access to the file. This checks the S_IWUSR flag is help in permissions.

Returns:
Throws:
SftpStatusException
SshException

canRead

public boolean canRead()
                throws SftpStatusException,
                       SshException
Determine whether the user has read access to the file. This checks the S_IRUSR flag is help in permissions.

Returns:
Throws:
SftpStatusException
SshException

isOpen

public boolean isOpen()
Determine whether the file is open.

Returns:

getHandle

public byte[] getHandle()
Get the open file handle

Returns:

getSFTPChannel

public SftpSubsystemChannel getSFTPChannel()
Get the SFTP subsystem channel that created this file object.

Returns:

getFilename

public java.lang.String getFilename()
Get the filename.

Returns:

getAttributes

public SftpFileAttributes getAttributes()
                                 throws SftpStatusException,
                                        SshException
Get the files attributes.

Returns:
Throws:
SftpStatusException
SshException

getAbsolutePath

public java.lang.String getAbsolutePath()
Get the absolute path

Returns:

close

public void close()
           throws SftpStatusException,
                  SshException
Close the file.

Throws:
SshException
SftpStatusException

isDirectory

public boolean isDirectory()
                    throws SftpStatusException,
                           SshException
Determine whether the file object is pointing to a directory. Note, if the file is a symbolic link pointing to a directory then false will be returned. Use SftpClient.isDirectoryOrLinkedDirectory(SftpFile) instead if you wish to follow links.

Returns:
Throws:
SftpStatusException
SshException

isFile

public boolean isFile()
               throws SftpStatusException,
                      SshException
Determine whether the file object is pointing to a file.

Returns:
Throws:
SftpStatusException
SshException

isLink

public boolean isLink()
               throws SftpStatusException,
                      SshException
Determine whether the file object is a symbolic link.

Returns:
Throws:
SftpStatusException
SshException

isFifo

public boolean isFifo()
               throws SftpStatusException,
                      SshException
Determine whether the file is pointing to a pipe.

Returns:
Throws:
SftpStatusException
SshException

isBlock

public boolean isBlock()
                throws SftpStatusException,
                       SshException
Determine whether the file is pointing to a block special file.

Returns:
Throws:
SftpStatusException
SshException

isCharacter

public boolean isCharacter()
                    throws SftpStatusException,
                           SshException
Determine whether the file is pointing to a character mode device.

Returns:
Throws:
SftpStatusException
SshException

isSocket

public boolean isSocket()
                 throws SftpStatusException,
                        SshException
Determine whether the file is pointing to a socket.

Returns:
Throws:
SftpStatusException
SshException


Copyright © 2003 3SP LTD. All Rights Reserved.