com.ssh.sft
Class Directory

java.lang.Object
  extended bycom.ssh.sft.SftLib
      extended bycom.ssh.sft.SftBase
          extended bycom.ssh.sft.File
              extended bycom.ssh.sft.Directory
All Implemented Interfaces:
SftLibConstants, com.ssh.sft.SshSftFileType, com.ssh.sft.SshSftSetstatMode

public class Directory
extends File
implements com.ssh.sft.SshSftSetstatMode

A remote directory. An instance of this class represents a particular directory at a particular location at a particular time. An instance will no longer be valid once the directory or its parent directories are moved or deleted.


Field Summary
static int SSH_SFT_SETSTAT_MODE_ADD
           
static int SSH_SFT_SETSTAT_MODE_OCTAL
           
static int SSH_SFT_SETSTAT_MODE_SUB
           
 
Fields inherited from class com.ssh.sft.File
SSH_SFT_FILE_TYPE_DIRECTORY, SSH_SFT_FILE_TYPE_REGULAR, SSH_SFT_FILE_TYPE_SPECIAL, SSH_SFT_FILE_TYPE_SYMLINK, SSH_SFT_FILE_TYPE_UNKNOWN
 
Fields inherited from interface com.ssh.sft.SftLibConstants
SSH_SFT_API_VERSION, SSH_SFT_DIR_RECURSIVE, SSH_SFT_HASH_MAX_BLOCK_SIZE, SSH_SFT_HASH_MAX_ITERATIONS, SSH_SFT_HASH_MIN_BLOCK_SIZE, SSH_SFT_REQUEST_MAX_NUM, SSH_SFT_REQUEST_MAX_SIZE
 
Method Summary
 File copy(Location dst)
          Copies the directory and its contents recursively.
 File copy(Location dst, Policies.CopyDir policy)
          Copies the directory and its contents recursively using the specified policy.
 Directory copy(Location dst, Policies.CopyDir policy, ProgressFactory factory)
          Copies the directory and its contents recursively using the specified policy and progresslistener factory.
 File getFile(String path)
          Returns a File object representing the file at a named path.
 Location getLocation(String path)
          Returns the Location of this file.
 File move(Location dst)
          Moves the directory and its contents recursively.
 Directory move(Location dst, Policies.MoveDir policy)
          Moves the directory and its contents recursively using the specified policy.
 Directory move(Location dst, Policies.MoveDir policy, ProgressFactory factory)
          Moves the directory and its contents recursively using the specified policy and progresslistener factory.
 DirHandle open()
          Returns an iterator over this directory's entries.
 void remove()
          Removes the directory and its contents recursively.
 void remove(Policies.RemoveDir policy)
          Removes the directory and its contents recursively using the specified policy.
 void setstat(long permissions, int mode, Policies.Dir policy)
          Sets the permissions of all files under this directory.
 void traverse(Policies.Dir policy)
          Traverses the directory and its contents recursively.
 
Methods inherited from class com.ssh.sft.File
copy, getAttributes, getGroup, getLocation, getOwner, getPath, getSession, getSize, getURI, rename, setAttributes
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SSH_SFT_SETSTAT_MODE_OCTAL

public static final int SSH_SFT_SETSTAT_MODE_OCTAL
See Also:
Constant Field Values

SSH_SFT_SETSTAT_MODE_ADD

public static final int SSH_SFT_SETSTAT_MODE_ADD
See Also:
Constant Field Values

SSH_SFT_SETSTAT_MODE_SUB

public static final int SSH_SFT_SETSTAT_MODE_SUB
See Also:
Constant Field Values
Method Detail

getLocation

public Location getLocation(String path)
                     throws SftException
Returns the Location of this file.

Parameters:
path -
Returns:
the Location of this file
Throws:
SftException

getFile

public File getFile(String path)
             throws SftException
Returns a File object representing the file at a named path.

Parameters:
path - the path to the desired file relative to this directory
Returns:
a File object representing the file at the named path
Throws:
NoSuchFileException - if no file exists at the named path
SftException

open

public DirHandle open()
               throws SftException
Returns an iterator over this directory's entries. The returned object can be used to traverse the contents of this directory in some unspecified order.

Returns:
an iterator over this directory's entries
Throws:
SftException

copy

public File copy(Location dst)
          throws SftException
Copies the directory and its contents recursively. This method overrides the default method File.copy(Location) and copies this directory and its contents to the destination location.

Overrides:
copy in class File
Parameters:
dst - the location to copy this directory to
Returns:
a Directory object representing the newly created directory
Throws:
SftException

copy

public File copy(Location dst,
                 Policies.CopyDir policy)
          throws SftException
Copies the directory and its contents recursively using the specified policy.

Parameters:
dst - the location to copy this directory to
policy - the policy to use to decide which files to copy, and to notify about errors
Returns:
a Directory object representing the newly created directory where this directory was moved
Throws:
SftException

copy

public Directory copy(Location dst,
                      Policies.CopyDir policy,
                      ProgressFactory factory)
               throws SftException
Copies the directory and its contents recursively using the specified policy and progresslistener factory.

Parameters:
dst - the location to copy this directory to
policy - the policy to use to decide which files to copy, and to notify about errors
factory - a progresslistener factory for tracking the progress of individual file copyings
Returns:
a Directory object representing the newly created directory where this directory was moved
Throws:
SftException

move

public File move(Location dst)
          throws SftException
Moves the directory and its contents recursively. This method overrides the default method File.move(Location) and copies this directory and its contents to the destination location, after which the original directory and its contents are removed. After the method returns, the directory represented by this object is removed and no further operations should be invoked on this object.

Overrides:
move in class File
Parameters:
dst - the location to move this directory to
Returns:
a Directory object representing the newly created directory
Throws:
SftException

move

public Directory move(Location dst,
                      Policies.MoveDir policy)
               throws SftException
Moves the directory and its contents recursively using the specified policy. This method moves this directory this directory and its contents to the destination location, after which the original directory and its contents are removed. After the method returns, the directory represented by this object is removed and no further operations should be invoked on this object.

Parameters:
dst - the location to move this directory to
policy - the policy to use to decide which files to copy and remove, and to notify about errors
Returns:
a Directory object representing the newly created directory where this directory was moved
Throws:
SftException

move

public Directory move(Location dst,
                      Policies.MoveDir policy,
                      ProgressFactory factory)
               throws SftException
Moves the directory and its contents recursively using the specified policy and progresslistener factory. This method moves this directory this directory and its contents to the destination location, after which the original directory and its contents are removed. After the method returns, the directory represented by this object is removed and no further operations should be invoked on this object.

Parameters:
dst - the location to move this directory to
policy - the policy to use to decide which files to copy and remove, and to notify about errors
factory - a progresslistener factory for tracking the progress of individual file copyings
Returns:
a Directory object representing the newly created directory where this directory was moved
Throws:
SftException

remove

public void remove()
            throws SftException
Removes the directory and its contents recursively. This method overrides the default method File.remove() and removes all the contents of this directory before removing the directory itself.

Overrides:
remove in class File
Throws:
SftException - if removing either the directory or its contents fails

remove

public void remove(Policies.RemoveDir policy)
            throws SftException
Removes the directory and its contents recursively using the specified policy. This method removes all the contents of this directory before removing the directory itself.

Throws:
SftException - if removing either the directory or its contents fails

traverse

public void traverse(Policies.Dir policy)
              throws SftException
Traverses the directory and its contents recursively. The order of the traversal is unspecified, and multiple entries may even be traversed concurrently. The given policy is used to relay information about the traversed files and to determine where the traversal should proceed.

Parameters:
policy - the directory traversal policy to use
Throws:
SftException

setstat

public void setstat(long permissions,
                    int mode,
                    Policies.Dir policy)
             throws SftException
Sets the permissions of all files under this directory.

Parameters:
permissions - the permissions as a standard Unix bitfield
mode - the mode to use when applying the permissions. Possible values are SshSftSetstatMode.SSH_SFT_SETSTAT_MODE_OCTAL for setting the permissions verbatim, SshSftSetstatMode.SSH_SFT_SETSTAT_MODE_ADD for combining the new permissions with the existing ones with a bitwise OR operation, and SshSftSetstatMode.SSH_SFT_SETSTAT_MODE_SUB for a bitwise AND NOT operation.
policy - the directory traversal policy to use
Throws:
SftException