public abstract class DiskSession extends Session
The DiskSession 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 SessionFactory.OpenDiskSession() method. The SessionFactory negotiates the appropriate SMB dialect with the remote server and creates the appropriate DiskSession derived object.
SessionFactory
Modifier and Type | Field and Description |
---|---|
static int |
Attributes |
static int |
DefaultInformationLevel |
static int |
WriteDate |
static int |
WriteTime |
Closed, DBGDumpPacket, DBGHexDump, DBGPacketType, DBGSigning, DEFAULT_BUFSIZE, m_pkt, m_treeid, NO_TRANSACTION, SecurityModeShare, SecurityModeUser
Modifier | Constructor and Description |
---|---|
protected |
DiskSession(PCShare shr,
int dialect)
Class constructor
|
Modifier and Type | Method and Description |
---|---|
void |
CloseSession()
Close this connection with the remote server share.
|
abstract void |
CreateDirectory(String dir)
Create a new directory on the remote file server.
|
abstract SMBFile |
CreateFile(String fname)
Create and open a file on the remote file server.
|
abstract void |
DeleteDirectory(String dir)
Delete the specified directory on the remote file server.
|
void |
DeleteFile(String fname)
Delete the specified file on the remote file server.
|
abstract void |
DeleteFile(String fname,
int attr)
Delete the specified file on the remote file server.
|
boolean |
FileExists(String fname)
Check if a file exists on the remote file server.
|
protected void |
finalize()
Finalize the object
|
abstract DiskInfo |
getDiskInformation()
Get disk information for this remote disk.
|
FileInfo |
getFileInformation(String fname)
Get file information for the specified file, returning the default information level
|
abstract FileInfo |
getFileInformation(String fname,
int level)
Get file information for the specified file.
|
abstract VolumeInfo |
getVolumeInformation()
Get the disk volume information
|
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(String dir)
Check if the specified file name is a directory.
|
protected boolean |
isValidFilePath(String path)
Check if a path looks like a valid file path
|
abstract SMBFile |
OpenFile(String fname,
int flags)
Open a file on the remote file server.
|
SMBInputStream |
OpenInputStream(String fname,
int flags)
Open a file as an input stream.
|
SMBOutputStream |
OpenOutputStream(String fname,
int flags)
Open a file as an output stream.
|
boolean |
RenameFile(String curnam,
String newnam)
Rename a file, or set of files, on the remote file server.
|
abstract boolean |
RenameFile(String curnam,
String newnam,
int attr)
Rename a file, or set of files, on the remote file server.
|
abstract void |
setFileAttributes(String fname,
int attrib)
Set file attributes for the specified file, using the file name
|
abstract void |
setFileInformation(SMBFile file,
FileInfo finfo)
Set file information for the specified file, using the file id
|
abstract void |
setFileInformation(String fname,
FileInfo finfo)
Set file information for the specified file.
|
void |
setWorkingDirectory(String wd)
Set the current working directory, relative to the share that is being accessed.
|
SearchContext |
StartSearch(String dir,
int attr)
Start a search of the specified directory returning the default information level
|
abstract SearchContext |
StartSearch(String dir,
int attr,
int level)
Start a search of the specified directory returning information for each file/directory
found.
|
allocatePacket, disableSMBSigning, enableSMBSigning, getCapabilities, getDefaultFlags, getDefaultFlags2, getDeviceType, getDialect, getDialectString, getDomain, getEncryptionKey, getLANManagerType, getMaximumMultiplexedRequests, getMaximumPacketSize, getMaximumVirtualCircuits, getNextMultiplexId, getNextSessionId, getOperatingSystem, getPassword, getPCShare, getProcessId, getSecurityMode, getServer, getSession, getSessionId, getShareName, getSMBSequence, getTreeId, getUserId, getUserName, hasActiveTransaction, hasDataAvailable, hasDebug, hasDebugOption, hasEncryptionKey, hasSMBSigning, isActive, isGuest, isUnicode, pingServer, pingServer, processAsynchResponse, setCapabilities, setDebug, setDefaultFlags, setDefaultFlags2, setDeviceType, setDialect, setDialectString, setDomain, setEncryptionKey, setGuest, setLANManagerType, setMaximumMultiplexedRequests, setMaximumPacketSize, setMaximumVirtualCircuits, setOperatingSystem, setPassword, setProcessId, setSecurityMode, setServer, setSession, setShareName, setSMBSequence, setTransactionMID, setTreeId, setUserId, setUserName, signTxPacket, supportsLargeFiles, supportsLevel2Oplocks, supportsLockAndRead, supportsNTFind, supportsNTSmbs, supportsNTStatusCodes, supportsRawMode, supportsRPCAPIs, supportsUnicode, toString, verifyRxPacket
public static final int DefaultInformationLevel
public static final int Attributes
public static final int WriteTime
public static final int WriteDate
protected DiskSession(PCShare shr, int dialect)
shr
- PCSharedialect
- intpublic void CloseSession() throws IOException, SMBException
CloseSession
in class Session
IOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic abstract void CreateDirectory(String dir) throws IOException, SMBException
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.IOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic abstract SMBFile CreateFile(String fname) throws IOException, SMBException
fname
- Remote file name string.IOException
- If an I/O error occursSMBException
- If an SMB error occurspublic abstract void DeleteDirectory(String dir) throws IOException, SMBException
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.IOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic void DeleteFile(String fname) throws IOException, SMBException
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.IOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic abstract void DeleteFile(String fname, int attr) throws IOException, SMBException
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.IOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic boolean FileExists(String fname)
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.public abstract DiskInfo getDiskInformation() throws IOException, SMBException
IOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic abstract FileInfo getFileInformation(String fname, int level) throws IOException, FileNotFoundException, SMBException
fname
- File name of the file to return information for.level
- Information level requiredIOException
- If an I/O error occurs.FileNotFoundException
- If the remote file does not exist.SMBException
- If an SMB level error occurspublic final FileInfo getFileInformation(String fname) throws IOException, FileNotFoundException, SMBException
fname
- File name of the file to return information for.IOException
- If an I/O error occurs.FileNotFoundException
- If the remote file does not exist.SMBException
- If an SMB level error occurspublic abstract VolumeInfo getVolumeInformation() throws IOException, SMBException
FileNotFoundException
- If the remote file does not exist.SMBException
- If an SMB level error occursIOException
public final String getWorkingDirectory()
public final boolean isClosed()
public abstract boolean isDirectory(String dir) throws IOException, SMBException
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.IOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic abstract SMBFile OpenFile(String fname, int flags) throws IOException, SMBException
fname
- Remote file name string.flags
- File open option flags.IOException
- If an I/O error occursSMBException
- If an SMB error occurspublic SMBInputStream OpenInputStream(String fname, int flags) throws IOException, SMBException
fname
- Remote file name string.flags
- File open option flags.IOException
- If an I/O error occursSMBException
- If an SMB error occurspublic SMBOutputStream OpenOutputStream(String fname, int flags) throws IOException, SMBException
fname
- Remote file name string.flags
- File open option flags.IOException
- If an I/O error occursSMBException
- If an SMB error occurspublic boolean RenameFile(String curnam, String newnam) throws IOException, SMBException
curnam
- Current file name string, may contain wildcards.newnam
- New file name.IOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic abstract boolean RenameFile(String curnam, String newnam, int attr) throws IOException, SMBException
curnam
- Current file name string, may contain wildcards.newnam
- New file name.attr
- Search attributes, to determine which file(s) to rename.IOException
- If an I/O error occurs.SMBException
- If an SMB level error occursFileAttribute
public abstract void setFileInformation(String fname, FileInfo finfo) throws IOException, SMBException
fname
- File name of the file to set information for.finfo
- File information containing the new values.IOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic abstract void setFileInformation(SMBFile file, FileInfo finfo) throws IOException, SMBException
file
- File to set information forfinfo
- File information containing new valuesIOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic abstract void setFileAttributes(String fname, int attrib) throws IOException, SMBException
fname
- File name of the file to set information for.attrib
- File attributes mask. @see org.alfresco.jlan.server.filesys.FileAttributeIOException
- If an I/O error occurs.SMBException
- If an SMB level error occurspublic final void setWorkingDirectory(String wd)
wd
- Working directory path string.public abstract SearchContext StartSearch(String dir, int attr, int level) throws IOException, SMBException
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. @see
org.alfresco.jlans.server.filesys.FileAttributelevel
- Information level to be returned. @see org.alfresco.jlan.smb.FileInfoLevelIOException
- If an I/O error occursSMBException
- If an SMB level error occurspublic final SearchContext StartSearch(String dir, int attr) throws IOException, SMBException
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. @see
org.alfresco.jlan.server.filesys.FileAttributeIOException
- If an I/O error occursSMBException
- If an SMB level error occursprotected final boolean isValidFilePath(String path)
path
- StringCopyright © 2005–2018 Alfresco Software. All rights reserved.