com.starla.smb
Class SMBDiskSession

java.lang.Object
  |
  +--com.starla.smb.SMBSession
        |
        +--com.starla.smb.SMBDiskSession
Direct Known Subclasses:
SMBCIFSDiskSession, SMBCoreDiskSession

public abstract class SMBDiskSession
extends SMBSession

The SMBDiskSession class provides disk, directory and file related methods on a remote disk share.

The disk session maintains a current working directory, initially set from the PCShare object that was used to open the disk session. Methods such as CreateDirectory (), DeleteDirectory (), OpenFile () etc. will prepend the working directory string to the specified file or directory string, unless the specified file or directory contains a path. The current working directory can be changed using the setWorkingDirectory () method.

A disk session is created using the SMBSessionFactory OpenDiskSession () method. The SMBSessionFactory negotiates the appropriate SMB dialect with the remote server and creates the appropriate SMBDiskSession derived object.


Field Summary
static int Attributes
          Set the file attributes, via the setFileInformation () method
static int WriteDate
          Set the file write date, via the setFileInformation () method
static int WriteTime
          Set the file write time, via the setFileInformation () method
 
Fields inherited from class com.starla.smb.SMBSession
DBGDumpPacket, DBGHexDump, DBGPacketType, DEFAULT_BUFSIZE, EncryptPass, RawRead, RawWrite, UserMode
 
Method Summary
abstract  void CloseSession()
          Close this connection with the remote server share.
abstract  boolean CreateDirectory(java.lang.String dir)
          Createa new directory on the remote file server.
abstract  boolean DeleteDirectory(java.lang.String dir)
          Delete the specified directory on the remote file server.
 void DeleteFile(java.lang.String fname)
          Delete the specified file on the remote file server.
abstract  void DeleteFile(java.lang.String fname, int attr)
          Delete the specified file on the remote file server.
 boolean FileExists(java.lang.String fname)
          Check if a file exists on the remote file server.
abstract  SMBDiskInfo getDiskInformation()
          Get disk information for this remote disk.
abstract  SMBFileInfo getFileInformation(java.lang.String fname)
          Get file information for the specified file.
 java.lang.String getWorkingDirectory()
          Get the current working directory, relative to the share that is being accessed.
 boolean isClosed()
          Detemine if the disk session has been closed.
abstract  boolean isDirectory(java.lang.String dir)
          Check if the specified file name is a directory.
abstract  SMBFile OpenFile(java.lang.String fname, int flags)
          Open a file on the remote file server.
 SMBInputStream OpenInputStream(java.lang.String fname, int flags)
          Open a file as an input stream.
 SMBOutputStream OpenOutputStream(java.lang.String fname, int flags)
          Open a file as an output stream.
 boolean RenameFile(java.lang.String curnam, java.lang.String newnam)
          Rename a file, or set of files, on the remote file server.
abstract  boolean RenameFile(java.lang.String curnam, java.lang.String newnam, int attr)
          Rename a file, or set of files, on the remote file server.
abstract  void setFileInformation(java.lang.String fname, SMBFileInfo finfo, int flags)
          Set file information for the specified file.
 void setWorkingDirectory(java.lang.String wd)
          Set the current working directory, relative to the share that is being accessed.
abstract  SMBSearchContext StartSearch(java.lang.String dir, int attr)
          Start a search of the specified directory returning information for each file/directory found.
 
Methods inherited from class com.starla.smb.SMBSession
getDeviceType, getDialect, getDomain, getEncryptionKey, getLANManagerType, getMaximumPacketSize, getOperatingSystem, getPassword, getServer, getSessionFlag, getSessionId, getShareName, getUserId, getUserName, hasDebugOption, isActive, isDebug, print, println, println, setDebug, setEncryptionKey, setRawMode, setSecurityMode, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Attributes

public static final int Attributes
Set the file attributes, via the setFileInformation () method

WriteTime

public static final int WriteTime
Set the file write time, via the setFileInformation () method

WriteDate

public static final int WriteDate
Set the file write date, via the setFileInformation () method
Method Detail

CloseSession

public abstract void CloseSession()
                           throws java.io.IOException
Close this connection with the remote server share.
Throws:
java.io.IOException - If an I/O error occurs.
Overrides:
CloseSession in class SMBSession

CreateDirectory

public abstract boolean CreateDirectory(java.lang.String dir)
                                 throws java.io.IOException
Createa new directory on the remote file server.
Parameters:
dir - Directory name string. If the directory name does not have a leading '\' the current working directory for this session will be prepended to the string.
Returns:
true if the directory was created, else false.
Throws:
java.io.IOException - If an I/O error occurs.

DeleteDirectory

public abstract boolean DeleteDirectory(java.lang.String dir)
                                 throws java.io.IOException
Delete the specified directory on the remote file server.
Parameters:
dir - Directory name string. If the directory name does not have a leading '\' the current working directory for this session will be preprended to the string.
Returns:
true if the directory was deleted, else false.
Throws:
java.io.IOException - If an I/O error occurs.

DeleteFile

public void DeleteFile(java.lang.String fname)
                throws java.io.IOException
Delete the specified file on the remote file server.
Parameters:
fname - File name of the remote file to delete. If the file name does not have a leading '\' the current working directory for this session will be prepended to the string. The string may contain wildcard characters to delete multiple files. '?' matches a single character and '*' matches none, one or more characters.
Throws:
java.io.IOException - If an I/O error occurs.

DeleteFile

public abstract void DeleteFile(java.lang.String fname,
                                int attr)
                         throws java.io.IOException
Delete the specified file on the remote file server.
Parameters:
fname - File name of the remote file to delete. If the file name does not have a leading '\' the current working directory for this session will be prepended to the string. The string may contain wildcard characters to delete multiple files. '?' matches a single character and '*' matches none, one or more characters.
attr - File attributes of the file(s) to delete.
Throws:
java.io.IOException - If an I/O error occurs.

FileExists

public boolean FileExists(java.lang.String fname)
Check if a file exists on the remote file server.
Parameters:
fname - File name to test for on the remote file server. If the file name does not start with a '\' then the working directory is prepended to the file name string.
Returns:
true if the file exists, else false.

getDiskInformation

public abstract SMBDiskInfo getDiskInformation()
                                        throws java.io.IOException
Get disk information for this remote disk.
Returns:
Disk information object, or null.
Throws:
java.io.IOException - If an I/O error occurs.

getFileInformation

public abstract SMBFileInfo getFileInformation(java.lang.String fname)
                                        throws java.io.IOException,
                                               java.io.FileNotFoundException
Get file information for the specified file.
Parameters:
fname - File name of the file to return information for.
Returns:
SMBFileInfo if the request was successful, else null.
Throws:
java.io.IOException - If an I/O error occurs.
java.io.FileNotFoundException - If the remote file does not exist.

getWorkingDirectory

public final java.lang.String getWorkingDirectory()
Get the current working directory, relative to the share that is being accessed.
Returns:
Current working directory path string.

isClosed

public final boolean isClosed()
Detemine if the disk session has been closed.
Returns:
true if the disk session has been closed, else false.

isDirectory

public abstract boolean isDirectory(java.lang.String dir)
                             throws java.io.IOException
Check if the specified file name is a directory.
Parameters:
dir - Directory name string. If the directory name does not have a leading '\' the current working directory for this session will be preprended to the string.
Returns:
true if the specified file name is a directory, else false.
Throws:
java.io.IOException - If an I/O error occurs.

OpenFile

public abstract SMBFile OpenFile(java.lang.String fname,
                                 int flags)
                          throws java.io.IOException
Open a file on the remote file server.
Parameters:
fname - Remote file name string.
flags - File open option flags.
Returns:
SMBFile for the opened file, else null.
Throws:
java.io.IOException - If an I/O error occurs

OpenInputStream

public SMBInputStream OpenInputStream(java.lang.String fname,
                                      int flags)
                               throws java.io.IOException
Open a file as an input stream.
Parameters:
fname - Remote file name string.
flags - File open option flags.
Returns:
SMBInputStream for the opened file, else null.
Throws:
java.io.IOException - If an I/O error occurs

OpenOutputStream

public SMBOutputStream OpenOutputStream(java.lang.String fname,
                                        int flags)
                                 throws java.io.IOException
Open a file as an output stream.
Parameters:
fname - Remote file name string.
flags - File open option flags.
Returns:
SMBOutputStream for the opened file, else null.
Throws:
java.io.IOException - If an I/O error occurs

RenameFile

public boolean RenameFile(java.lang.String curnam,
                          java.lang.String newnam)
                   throws java.io.IOException
Rename a file, or set of files, on the remote file server.
Parameters:
curnam - Current file name string, may contain wildcards.
newnam - New file name.
attr - Search attributes, to determine which file(s) to rename.
Returns:
true if the file(s) were renamed, else false
Throws:
java.io.IOException - If an I/O error occurs.

RenameFile

public abstract boolean RenameFile(java.lang.String curnam,
                                   java.lang.String newnam,
                                   int attr)
                            throws java.io.IOException
Rename a file, or set of files, on the remote file server.
Parameters:
curnam - Current file name string, may contain wildcards.
newnam - New file name.
attr - Search attributes, to determine which file(s) to rename.
Returns:
true if the file(s) were renamed, else false
Throws:
java.io.IOException - If an I/O error occurs.

setFileInformation

public abstract void setFileInformation(java.lang.String fname,
                                        SMBFileInfo finfo,
                                        int flags)
                                 throws java.io.IOException
Set file information for the specified file.
Parameters:
fname - File name of the file to set information for.
finfo - File information containing the new values.
flags - Bit mask of the information to set.
Throws:
java.io.IOException - If an I/O error occurs.

setWorkingDirectory

public final void setWorkingDirectory(java.lang.String wd)
Set the current working directory, relative to the share that is being accessed.
Parameters:
wd - Working directory path string.

StartSearch

public abstract SMBSearchContext StartSearch(java.lang.String dir,
                                             int attr)
                                      throws java.io.IOException
Start a search of the specified directory returning information for each file/directory found.
Parameters:
dir - Directory/file name string, which may contain wildcards. If the directory string does not start with a '\' then the directory name is prepended with the current working directory.
attr - Search attributes, to determine the types of files/directories returned.
Returns:
SMBSearchContext for this search, else null
Throws:
java.io.IOException - If an I/O error occurs