org.gnu.jcifs
Class DiskImpl

java.lang.Object
  |
  +--org.gnu.jcifs.SessionImpl
        |
        +--org.gnu.jcifs.DiskImpl
All Implemented Interfaces:
CifsDisk, CifsSession

class DiskImpl
extends SessionImpl
implements CifsDisk

CifsDisk implements the disk operations. CifsDisk cannot be instantiated directly.

Since:
1.0
See Also:
CifsServiceManager#connectDisk, CifsService

Field Summary
protected static FileInfoComparator fFileInfoComparator
           
(package private) static int O_CREAT
          create and open file
(package private) static int O_EXCL
          open only if file doesn't already exist
(package private) static int O_RDONLY
          open for reading only
(package private) static int O_RDWR
          open for reading and writing
(package private) static int O_TRUNC
          open and truncate
(package private) static int O_WRONLY
          open for writing only
static int SM_DENY_NONE
          Allow all actions
static int SM_DENY_READ_EXEC
          Deny read/execute
static int SM_DENY_WRITE
          Deny write
static int SM_EXCLUSIVE
          Deny read/write/execute (exclusive)
 
Fields inherited from class org.gnu.jcifs.SessionImpl
CAP_BULK_TRANSFER, CAP_COMPRESSED_DATA, CAP_DFS, CAP_EXTENDED_SECURITY, CAP_LARGE_FILES, CAP_LEVEL_II_OPLOCKS, CAP_LOCK_AND_READ, CAP_MPX_MODE, CAP_NT_FIND, CAP_NT_SMBS, CAP_RAW_MODE, CAP_RPC_REMOTE_APIS, CAP_STATUS32, CAP_UNICODE, fCallerProperties, fCapabilities, fEncryptionKeyLen, fExtendedSecurity, fLoggedAsGuest, fMaxBufferSize, fMaxPendingMPRequests, fMaxRawSize, fMaxVCs, fMsg, fNBTSession, fPID, fProtocol, fSecurityMode, fServerLanMan, fServerOS, fServerPrimaryDomain, fSessionKey, fSessionName, fShare, fSystemTime, fTID, fTimeZone, fUID, LANMAN_1_0, LM_1_2X002, NT_LM_0_12, SMB_CORE, SUPPORTED_DIALECTS
 
Constructor Summary
(package private) DiskImpl(java.lang.String sessionname, int prot, Share share, NBTSession nbt, SMBMessage msg)
           
 
Method Summary
protected  boolean checkDirectory(java.lang.String dirname)
          Checks directory (name not changed)
(package private)  void closeFile(FileHandle handle, boolean touch)
           
 void deleteFile(java.lang.String file)
          Deletes the given file
 boolean directoryExists(java.lang.String dirname)
          Checks if directory exists
protected static java.lang.String extractDir(java.lang.String file)
           
protected static java.lang.String extractName(java.lang.String file)
           
protected  java.lang.String getAbsPathName(java.lang.String name, boolean relative)
           
 long getFile(java.lang.String file, java.io.OutputStream out)
          Gets the file from the server and writes the content to the given output stream.
 long getFile(java.lang.String file, java.io.Writer out)
          Gets the file from the server and writes the content to the given output stream.
 CifsFileInfo getFileInfo(java.lang.String file)
          Returns information about the given file
 CifsFileSystemInfo getFileSystemInfo()
          Returns informations about the filesystem
(package private)  int getSortPosition()
           
 CifsFileInfo[] listFilesInfo(java.lang.String file, int searchattr, boolean sort)
          Enumerates informations about the files
 java.lang.String[] listFilesName(java.lang.String file, int searchattr, boolean sort)
          Enumerates file names
 void mkdir(java.lang.String dirname)
          Creates the given directory on the server
(package private)  FileHandle openFile(java.lang.String file, int flags, int sharemode)
           
 long putFile(java.lang.String file, java.io.InputStream in)
          Puts the data from the input stream to the given remote file.
 long putFile(java.lang.String file, java.io.Reader in)
          Puts the data from the input stream to the given remote file.
(package private)  int readFile(FileHandle handle, long offset, byte[] buf, int obuf, int len)
           
(package private)  void readFile(FileHandle handle, long offset, int len)
           
 void renameFile(java.lang.String oldfile, java.lang.String newfile)
          Renames the old file to the new file (also hidden and system files)
 void renameFile(java.lang.String oldfile, java.lang.String newfile, int searchattr)
          Renames file corresponding to the search attributes
 void rmdir(java.lang.String dirname)
          Removes directory
 void setFileAttribute(java.lang.String file, int attr, boolean set)
          Sets or resets file attributes (Cifs.FILE_ATTR_*)
 java.lang.String toString()
           
(package private)  int writeFile(FileHandle handle, long offset, byte[] buf, int obuf, int lbuf)
           
(package private)  int writeFile(FileHandle handle, long offset, char[] buf, int obuf, int lbuf)
           
 
Methods inherited from class org.gnu.jcifs.SessionImpl
addSession, allocateSMBMessage, checkConnection, connect, disconnect, echo, enumerateSessions, finalize, getConnectTime, getNetBIOSName, getProperty, getServerAddress, getServerLanMan, getServerOS, getServerPrimaryDomain, getServerTime, getServerTimeZone, getSessionName, getSessions, getShareName, howManyBytesCanWeSend, isConnected, isUserLevelSecurity, lookupSession, negotiate, promptLogin, receiveTransaction, reconnect, removeSession, sendTransaction, sendTransaction2, setAllowAutoReconnection, setProperty, setupSMBMessage, setupSMBMessageSecondary
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.gnu.jcifs.CifsSession
disconnect, echo, getConnectTime, getNetBIOSName, getProperty, getServerAddress, getServerLanMan, getServerOS, getServerPrimaryDomain, getServerTime, getServerTimeZone, getSessionName, getShareName, isConnected, isUserLevelSecurity, reconnect, setAllowAutoReconnection, setProperty
 

Field Detail

SM_EXCLUSIVE

public static final int SM_EXCLUSIVE
Deny read/write/execute (exclusive)

SM_DENY_WRITE

public static final int SM_DENY_WRITE
Deny write

SM_DENY_READ_EXEC

public static final int SM_DENY_READ_EXEC
Deny read/execute

SM_DENY_NONE

public static final int SM_DENY_NONE
Allow all actions

O_RDONLY

static final int O_RDONLY
open for reading only

O_WRONLY

static final int O_WRONLY
open for writing only

O_RDWR

static final int O_RDWR
open for reading and writing

O_CREAT

static final int O_CREAT
create and open file

O_TRUNC

static final int O_TRUNC
open and truncate

O_EXCL

static final int O_EXCL
open only if file doesn't already exist

fFileInfoComparator

protected static FileInfoComparator fFileInfoComparator
Constructor Detail

DiskImpl

DiskImpl(java.lang.String sessionname,
         int prot,
         Share share,
         NBTSession nbt,
         SMBMessage msg)
   throws java.io.IOException
Method Detail

getFile

public long getFile(java.lang.String file,
                    java.io.OutputStream out)
             throws java.io.IOException
Gets the file from the server and writes the content to the given output stream. The file will not not locked
Specified by:
getFile in interface CifsDisk
Parameters:
file - remote file name (relativ to share)
out - output stream
Returns:
number of bytes
Throws:
java.io.IOException - if an I/O error occurs.

getFile

public long getFile(java.lang.String file,
                    java.io.Writer out)
             throws java.io.IOException
Gets the file from the server and writes the content to the given output stream. The file will not not locked
Specified by:
getFile in interface CifsDisk
Parameters:
file - remote file name (relativ to share)
out - writer
Returns:
number of bytes
Throws:
java.io.IOException - if an I/O error occurs.

putFile

public long putFile(java.lang.String file,
                    java.io.Reader in)
             throws java.io.IOException
Puts the data from the input stream to the given remote file. The file will not not locked
Specified by:
putFile in interface CifsDisk
Parameters:
file - remote file name (relativ to share)
in - input reader
Returns:
number of bytes
Throws:
java.io.IOException - if an I/O error occurs.

putFile

public long putFile(java.lang.String file,
                    java.io.InputStream in)
             throws java.io.IOException
Puts the data from the input stream to the given remote file. The file will not not locked
Specified by:
putFile in interface CifsDisk
Parameters:
file - remote file name (relativ to share)
in - input stream
Returns:
number of bytes
Throws:
java.io.IOException - if an I/O error occurs.

deleteFile

public void deleteFile(java.lang.String file)
                throws java.io.IOException
Deletes the given file
Specified by:
deleteFile in interface CifsDisk
Parameters:
file - remote file name
Throws:
java.io.IOException - if an I/O error occurs.

renameFile

public void renameFile(java.lang.String oldfile,
                       java.lang.String newfile)
                throws java.io.IOException
Renames the old file to the new file (also hidden and system files)
Specified by:
renameFile in interface CifsDisk
Parameters:
oldfile - old file
newfile - new file
Throws:
java.io.IOException - if an I/O error occurs.

renameFile

public void renameFile(java.lang.String oldfile,
                       java.lang.String newfile,
                       int searchattr)
                throws java.io.IOException
Renames file corresponding to the search attributes
Specified by:
renameFile in interface CifsDisk
Parameters:
oldfile - old file
newfile - new file
searchattr - search attributes (see CifsFileInfo.FILE_ATTR_*)
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
CifsFile

setFileAttribute

public void setFileAttribute(java.lang.String file,
                             int attr,
                             boolean set)
                      throws java.io.IOException
Sets or resets file attributes (Cifs.FILE_ATTR_*)
Specified by:
setFileAttribute in interface CifsDisk
Parameters:
file - file name
attr - new file attributes
set - if true sets the given attributes otherwise resets it
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
CifsFile

mkdir

public void mkdir(java.lang.String dirname)
           throws java.io.IOException
Creates the given directory on the server
Specified by:
mkdir in interface CifsDisk
Parameters:
dirname - directory name
Throws:
java.io.IOException - if an I/O error occurs.

rmdir

public void rmdir(java.lang.String dirname)
           throws java.io.IOException
Removes directory
Specified by:
rmdir in interface CifsDisk
Parameters:
dirname - directory name
Throws:
java.io.IOException - if an I/O error occurs.

directoryExists

public boolean directoryExists(java.lang.String dirname)
                        throws java.io.IOException
Checks if directory exists
Specified by:
directoryExists in interface CifsDisk
Parameters:
dirname - directory name
Returns:
true if directory exits
Throws:
java.io.IOException - if an I/O error occurs.

checkDirectory

protected boolean checkDirectory(java.lang.String dirname)
                          throws java.io.IOException
Checks directory (name not changed)
Parameters:
dirname - directory name
Returns:
true if yes

getFileSystemInfo

public CifsFileSystemInfo getFileSystemInfo()
                                     throws java.io.IOException
Returns informations about the filesystem
Specified by:
getFileSystemInfo in interface CifsDisk
Returns:
CifsFileSystemInfo filesystem informations
Throws:
java.io.IOException - if an I/O error occurs.

getFileInfo

public CifsFileInfo getFileInfo(java.lang.String file)
                         throws java.io.IOException
Returns information about the given file
Specified by:
getFileInfo in interface CifsDisk
Parameters:
file - file name
Returns:
CifsFileInfo
Throws:
java.io.IOException - if an I/O error occurs.

listFilesInfo

public CifsFileInfo[] listFilesInfo(java.lang.String file,
                                    int searchattr,
                                    boolean sort)
                             throws java.io.IOException
Enumerates informations about the files
Specified by:
listFilesInfo in interface CifsDisk
Parameters:
file - file name (with wildcards)
searchattr - file attributes (see CifsFile.FILE_ATTR_*)
sort - if true names will be sorted
Returns:
array of CifsFileInfo elements
Throws:
java.io.IOException - if an I/O error occurs.

listFilesName

public java.lang.String[] listFilesName(java.lang.String file,
                                        int searchattr,
                                        boolean sort)
                                 throws java.io.IOException
Enumerates file names
Specified by:
listFilesName in interface CifsDisk
Parameters:
file - file name (with wildcards)
searchattr - file attributes
sort - if true names will be sorted
Returns:
array of java.lang.String elements
Throws:
java.io.IOException - if an I/O error occurs.

openFile

FileHandle openFile(java.lang.String file,
                    int flags,
                    int sharemode)
              throws java.io.IOException

closeFile

void closeFile(FileHandle handle,
               boolean touch)
         throws java.io.IOException

readFile

int readFile(FileHandle handle,
             long offset,
             byte[] buf,
             int obuf,
             int len)
       throws java.io.IOException

readFile

void readFile(FileHandle handle,
              long offset,
              int len)
        throws java.io.IOException

writeFile

int writeFile(FileHandle handle,
              long offset,
              char[] buf,
              int obuf,
              int lbuf)
        throws java.io.IOException

writeFile

int writeFile(FileHandle handle,
              long offset,
              byte[] buf,
              int obuf,
              int lbuf)
        throws java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getAbsPathName

protected java.lang.String getAbsPathName(java.lang.String name,
                                          boolean relative)

extractDir

protected static java.lang.String extractDir(java.lang.String file)

extractName

protected static java.lang.String extractName(java.lang.String file)

getSortPosition

int getSortPosition()
Overrides:
getSortPosition in class SessionImpl