public abstract class SMBFile extends Object
This is an abstract class that defines the standard SMB file methods.
Modifier and Type | Field and Description |
---|---|
static int |
Closed |
static int |
EndOfFile |
protected int |
m_FID |
protected int |
m_rxlen |
protected int |
m_rxoffset |
protected SMBPacket |
m_rxpkt |
protected long |
m_rxpos |
protected Session |
m_sess |
protected int |
m_txlen |
protected int |
m_txoffset |
protected SMBPacket |
m_txpkt |
protected long |
m_txpos |
Modifier | Constructor and Description |
---|---|
protected |
SMBFile(Session sess,
FileInfo finfo,
int fid)
Construct an SMBFile on the specified SMB session.
|
Modifier and Type | Method and Description |
---|---|
SMBInputStream |
asInputStream()
Create an input stream using this file
|
SMBOutputStream |
asOutputStream()
Create an output stream using this file
|
boolean |
atEndOfFile()
Check if the end of file has been reached.
|
int |
Available()
Return the number of bytes that are available for reading without blocking the input stream.
|
void |
clearEndOfFile()
Clear the end of file flag
|
void |
Close()
Close the remote file, let the remote server set the last write date/time
|
abstract void |
Close(SMBDate wrDateTime)
Close the remote file.
|
protected void |
finalize()
Finalize, object destruction.
|
abstract void |
Flush()
Flush any buffered data for this file.
|
int |
getAttributes()
Return the file attributes
|
int |
getFileId()
Return the file id
|
String |
getFileName()
Get the file name string.
|
String |
getFilePath()
Get the file path string.
|
long |
getFileSize()
Get the file size, in bytes.
|
long |
getReadPosition()
Return the current file read position
|
protected Session |
getSession()
Get the session that this file is associated with.
|
long |
getWritePosition()
Return the current write position
|
protected boolean |
hasStateFlag(int flg)
Check if the specified state flag is set
|
boolean |
isClosed()
Check if the file has been closed.
|
boolean |
isDirectory()
Determine if this file is a directory
|
boolean |
isHidden()
Determine if this file is hidden
|
boolean |
isReadOnly()
Determine if this file is read-only
|
boolean |
isSystem()
Determine if this file is a system file
|
abstract void |
Lock(long offset,
long len)
Lock a range of bytes within the file
|
int |
Read(byte[] buf)
Read a block of data from the file.
|
abstract int |
Read(byte[] buf,
int siz,
int offset)
Read a block of data from the file.
|
void |
refreshFileInformation()
Refresh the file information for an open file
|
abstract long |
Seek(long pos,
int typ)
Seek to the specified point in the file.
|
protected void |
setFileInformation(FileInfo fInfo)
Set/update the file information
|
protected void |
setStateFlag(int flag,
boolean sts)
Set a file state flag.
|
String |
toString()
Return the SMB file as a string
|
abstract void |
Unlock(long offset,
long len)
Unlock a range of bytes within the file
|
int |
Write(byte[] buf)
Write a block of data to the file.
|
abstract int |
Write(byte[] buf,
int siz,
int offset)
Write a block of data to the file.
|
int |
Write(String str)
Write a string to the file.
|
public static final int EndOfFile
public static final int Closed
protected Session m_sess
protected int m_FID
protected SMBPacket m_rxpkt
protected SMBPacket m_txpkt
protected long m_rxpos
protected long m_txpos
protected int m_rxoffset
protected int m_rxlen
protected int m_txoffset
protected int m_txlen
public final boolean atEndOfFile()
public final void clearEndOfFile()
public final int Available()
public abstract void Close(SMBDate wrDateTime) throws IOException, SMBException
wrDateTime
- Set the last write date/time, or null to let the server set the date/timeIOException
- If an I/O error occursSMBException
- If an SMB level error occurspublic final void Close() throws IOException, SMBException
IOException
- If an I/O error occursSMBException
- If an SMB level error occursprotected void finalize()
public abstract void Flush() throws IOException, SMBException
IOException
- If an I/O error occursSMBException
- If an SMB level error occurspublic final int getAttributes()
public final String getFileName()
public final String getFilePath()
public final long getFileSize()
public final int getFileId()
protected final Session getSession()
public final long getReadPosition()
public final long getWritePosition()
public final boolean isClosed()
public final boolean isDirectory()
public final boolean isHidden()
public final boolean isReadOnly()
public final boolean isSystem()
public abstract int Read(byte[] buf, int siz, int offset) throws IOException, SMBException
buf
- Byte buffer to receive the data.siz
- Maximum length of data to receive.offset
- Offset within buffer to place received data.IOException
- If an I/O error occursSMBException
- If an SMB level error occurspublic final int Read(byte[] buf) throws IOException, SMBException
buf
- Byte buffer to receive the data.IOException
- If an I/O error occursSMBException
- If an SMB level error occurspublic abstract int Write(byte[] buf, int siz, int offset) throws IOException, SMBException
buf
- Byte buffer containing data to be written.siz
- Length of data to be written.offset
- Offset within buffer to start writing data from.IOException
- If an I/O error occursSMBException
- If an SMB level error occurspublic final int Write(byte[] buf) throws IOException, SMBException
buf
- Byte buffer containing data to be written.IOException
- If an I/O error occursSMBException
- If an SMB level error occurspublic final int Write(String str) throws IOException, SMBException
str
- String to be written to the fileIOException
- If an I/O error occursSMBException
- If an SMB level error occurspublic abstract long Seek(long pos, int typ) throws IOException, SMBException
pos
- Relative offsettyp
- Seek type. @see org.alfresco.jlan.smb.SeekTypeIOException
SMBException
- If an SMB level error occurspublic abstract void Lock(long offset, long len) throws IOException, SMBException
offset
- Offset within the file to start locklen
- Number of bytes to lockIOException
SMBException
- If an SMB level error occurspublic abstract void Unlock(long offset, long len) throws IOException, SMBException
offset
- Offset within the file to unlocklen
- Number of bytes to unlockIOException
SMBException
- If an SMB level error occursprotected void setStateFlag(int flag, boolean sts)
flag
- File state flag to set/clear.sts
- New file flag state, true or false.protected final void setFileInformation(FileInfo fInfo)
fInfo
- FileInfopublic final SMBInputStream asInputStream() throws SMBException
SMBException
- If the file is a directorypublic final SMBOutputStream asOutputStream() throws SMBException
SMBException
- If the file is a directorypublic void refreshFileInformation() throws IOException, SMBException
IOException
SMBException
protected final boolean hasStateFlag(int flg)
flg
- intCopyright © 2005–2018 Alfresco Software. All rights reserved.