public abstract class NetworkFile
extends java.lang.Object
The network file represents a file or directory on a filesystem. The server keeps track of the open files on a per session basis.
This class may be extended as required by your own disk driver class.
Modifier and Type | Field and Description |
---|---|
static int |
ATTRIBUTESONLY |
static int |
Created |
static int |
DelayedClose |
static int |
DelayedWriteError |
static int |
DeleteOnClose |
static int |
IOPending |
protected long |
m_accessDate |
protected int |
m_allowedAccess |
protected int |
m_attrib |
protected boolean |
m_closed |
protected long |
m_createDate |
protected int |
m_dirId |
protected int |
m_fid |
protected long |
m_fileSize |
protected java.lang.String |
m_fullName |
protected int |
m_grantedAccess |
protected long |
m_modifyDate |
protected java.lang.String |
m_name |
protected int |
m_streamId |
protected java.lang.String |
m_streamName |
protected long |
m_uniqueId |
protected int |
m_writeCount |
static int |
READONLY |
static int |
READWRITE |
static int |
WRITEONLY |
Constructor and Description |
---|
NetworkFile(int fid)
Create a network file object with the specified file identifier.
|
NetworkFile(int fid,
int did)
Create a network file with the specified file and parent directory ids
|
NetworkFile(int fid,
int stid,
int did)
Create a network file with the specified file id, stream id and parent directory id
|
NetworkFile(java.lang.String name)
Create a network file object with the specified file/directory name.
|
Modifier and Type | Method and Description |
---|---|
void |
addLock(FileLock lock)
Add a lock to the active lock list
|
boolean |
allowsOpenCloseViaNetworkFile()
Indicate whether the file can be opened/closed via the NetworkFile methods rather than the DiskInterface.
|
void |
close()
Close the file
|
abstract void |
closeFile()
Implementation of close
|
abstract void |
flushFile()
Flush any buffered output to the file
|
long |
getAccessDate()
Return the file access date/time
|
FileAccessToken |
getAccessToken()
Return the access token
|
int |
getAllowedAccess()
Return the allowed file access mode
|
long |
getCreationDate()
Return the file creation date/time
|
int |
getDirectoryId()
Return the parent directory identifier
|
int |
getFileAttributes()
Return the file attributes.
|
int |
getFileId()
Return the file identifier.
|
long |
getFileSize()
Get the file size, in bytes.
|
int |
getFileSizeInt()
Get the file size, in bytes.
|
java.lang.String |
getFullName()
Return the full name, relative to the share.
|
java.lang.String |
getFullNameStream()
Return the full name including the stream name, relative to the share.
|
int |
getGrantedAccess()
Return the granted file access mode.
|
java.lang.String |
getGrantedAccessAsString()
Return the granted access as a string
|
FileLock |
getLockAt(int idx)
Get the details of an active lock from the list
|
FileLockList |
getLockList()
Return the lock list
|
long |
getModifyDate()
Return the file modify date/time
|
java.lang.String |
getName()
Return the file/directory name.
|
OpLockDetails |
getOpLock()
Return the oplock details
|
int |
getProtocolId()
Return the protocol file id/handle
|
int |
getStreamId()
Return the stream id, zero indicates the main file stream
|
java.lang.String |
getStreamName()
Return the stream name, if this is a stream
|
long |
getUniqueId()
Return the unique file identifier
|
int |
getWriteCount()
Get the write count for the file
|
boolean |
hasAccessDate()
Determine if the file access date/time is valid
|
boolean |
hasAccessToken()
Check if the file has an access token
|
boolean |
hasCreationDate()
Determine if the file creation date/time is valid
|
boolean |
hasDelayedClose()
Check if the delayed close is set
|
boolean |
hasDelayedWriteError()
Check if a delayed write error has occurred on this file
|
boolean |
hasDeleteOnClose()
Check if the delete on close flag has been set for this file
|
boolean |
hasIOPending()
Check if the file has an I/O request pending
|
boolean |
hasLocks()
Check if there are active locks on this file by this session
|
boolean |
hasModifyDate()
Determine if the file modification date/time is valid
|
boolean |
hasNTAttribute(int attr)
Check for NT attributes
|
boolean |
hasOpLock()
Check if there is an oplock on this file/handle
|
void |
incrementWriteCount()
Increment the write count
|
boolean |
isArchived()
Return the archived attribute status
|
boolean |
isClosed()
Determine if the file has been closed.
|
boolean |
isDirectory()
Return the directory file attribute status.
|
boolean |
isForce() |
boolean |
isHidden()
Return the hidden file attribute status.
|
boolean |
isReadOnly()
Return the read-only file attribute status.
|
boolean |
isStream()
Check if this is a stream file
|
boolean |
isSystem()
Return the system file attribute status.
|
int |
numberOfLocks()
Return the count of active locks
|
abstract void |
openFile(boolean createFlag)
Open the file
|
abstract int |
readFile(byte[] buf,
int len,
int pos,
long fileOff)
Read from the file.
|
void |
removeAllLocks()
Remove all locks from the lock list
|
void |
removeLock(FileLock lock)
Remove a lock from the active lock list
|
abstract long |
seekFile(long pos,
int typ)
Seek to the specified file position.
|
void |
setAccessDate(long dattim)
Set the file access date/time
|
void |
setAccessToken(FileAccessToken token)
Set, or clear, the access token
|
void |
setAllowedAccess(int mode)
Set the allowed access mode
|
void |
setAttributes(int attrib)
Set the file attributes, as specified by the SMBFileAttribute class.
|
void |
setClosed(boolean b)
Set the file closed state.
|
void |
setCreationDate(long dattim)
Set the file creation date/time
|
void |
setDelayedClose(boolean delayClose)
Set or clear the delayed close flag
|
void |
setDelayedWriteError(boolean err)
Set or clear the delayed write error flag
|
void |
setDeleteOnClose(boolean del)
Set, or clear, the delete on close flag
|
void |
setDirectoryId(int dirId)
Set the parent directory identifier
|
void |
setFileId(int fid)
Set the file identifier.
|
void |
setFileSize(int siz)
Set the file size.
|
void |
setFileSize(long siz)
Set the file size.
|
void |
setForce(boolean force) |
void |
setFullName(java.lang.String name)
Set the full file name, relative to the share.
|
void |
setGrantedAccess(int mode)
Set the granted file access mode.
|
void |
setIOPending(boolean pending)
Set/clear the I/O pending flag
|
void |
setModifyDate(long dattim)
Set the file modification date/time
|
void |
setName(java.lang.String name)
Set the file name.
|
void |
setOpLock(OpLockDetails oplock)
Set/clear the oplock on this file
|
void |
setProtocolId(int id)
Set the protocol level file id/handle
|
void |
setStatusFlag(int flag,
boolean sts)
Set/clear a file status flag
|
void |
setStreamId(int id)
Set the stream id
|
void |
setStreamName(java.lang.String name)
Set the stream name
|
protected void |
setUniqueId(int fid,
int did)
Set the unique id using the file and directory id
|
protected void |
setUniqueId(long id)
Set the unique file identifier
|
protected void |
setUniqueId(java.lang.String path)
Set the unique id using the full path string
|
java.lang.String |
toString()
Return the file details as a string
|
abstract void |
truncateFile(long siz)
Truncate the file to the specified file size
|
boolean |
wasCreated()
Check if the file was created during the open
|
abstract void |
writeFile(byte[] buf,
int len,
int pos,
long fileOff)
Write a block of data to the specified offset within file.
|
public static final int ATTRIBUTESONLY
public static final int READONLY
public static final int WRITEONLY
public static final int READWRITE
public static final int IOPending
public static final int DeleteOnClose
public static final int DelayedWriteError
public static final int Created
public static final int DelayedClose
protected int m_fid
protected int m_dirId
protected long m_uniqueId
protected java.lang.String m_name
protected java.lang.String m_streamName
protected int m_streamId
protected java.lang.String m_fullName
protected int m_attrib
protected long m_fileSize
protected long m_createDate
protected long m_modifyDate
protected long m_accessDate
protected int m_grantedAccess
protected int m_allowedAccess
protected boolean m_closed
protected int m_writeCount
public NetworkFile(int fid)
fid
- intpublic NetworkFile(int fid, int did)
fid
- intdid
- intpublic NetworkFile(int fid, int stid, int did)
fid
- intstid
- intdid
- intpublic NetworkFile(java.lang.String name)
name
- File name string.public final int getDirectoryId()
public final int getFileAttributes()
public final int getFileId()
public final long getFileSize()
public final int getFileSizeInt()
public final java.lang.String getFullName()
public final java.lang.String getFullNameStream()
public final int getGrantedAccess()
public final java.lang.String getGrantedAccessAsString()
public final int getAllowedAccess()
public java.lang.String getName()
public final int getStreamId()
public final java.lang.String getStreamName()
public final long getUniqueId()
public final boolean isClosed()
public final boolean isDirectory()
public final boolean isHidden()
public final boolean isReadOnly()
public final boolean isSystem()
public final boolean isArchived()
public final boolean isStream()
public final boolean hasLocks()
public final boolean hasNTAttribute(int attr)
attr
- intpublic final boolean hasAccessDate()
public final long getAccessDate()
public final boolean hasCreationDate()
public final long getCreationDate()
public final boolean hasDelayedWriteError()
public final boolean hasDeleteOnClose()
public final boolean hasIOPending()
public final boolean hasDelayedClose()
public final boolean wasCreated()
public boolean hasModifyDate()
public final long getModifyDate()
public final int getWriteCount()
public final void incrementWriteCount()
public final int getProtocolId()
public final void setAttributes(int attrib)
attrib
- intpublic final void setDeleteOnClose(boolean del)
del
- booleanpublic final void setDirectoryId(int dirId)
dirId
- intpublic final void setFileId(int fid)
fid
- intpublic final void setFileSize(long siz)
siz
- longpublic final void setFileSize(int siz)
siz
- intpublic final void setFullName(java.lang.String name)
name
- Stringpublic final void setGrantedAccess(int mode)
mode
- intpublic final void setAllowedAccess(int mode)
mode
- intpublic final void setName(java.lang.String name)
name
- Stringpublic final void setIOPending(boolean pending)
pending
- booleanpublic final void setStreamId(int id)
id
- intpublic final void setStreamName(java.lang.String name)
name
- Stringpublic final void setClosed(boolean b)
b
- booleanpublic final void setAccessDate(long dattim)
dattim
- longpublic final void setCreationDate(long dattim)
dattim
- longpublic final void setDelayedWriteError(boolean err)
err
- booleanpublic final void setDelayedClose(boolean delayClose)
delayClose
- booleanpublic final void setModifyDate(long dattim)
dattim
- longpublic final void setStatusFlag(int flag, boolean sts)
flag
- intsts
- booleanpublic final void addLock(FileLock lock)
lock
- FileLockpublic final void removeLock(FileLock lock)
lock
- FileLockpublic final void removeAllLocks()
public final int numberOfLocks()
public final FileLock getLockAt(int idx)
idx
- intpublic final FileLockList getLockList()
public final boolean hasOpLock()
public final OpLockDetails getOpLock()
public final void setOpLock(OpLockDetails oplock)
oplock
- OpLockDetailsprotected final void setUniqueId(long id)
id
- longprotected final void setUniqueId(int fid, int did)
fid
- intdid
- intprotected final void setUniqueId(java.lang.String path)
path
- Stringpublic final void setProtocolId(int id)
id
- intpublic final boolean hasAccessToken()
public final FileAccessToken getAccessToken()
public final void setAccessToken(FileAccessToken token)
token
- FileAccessTokenpublic abstract void openFile(boolean createFlag) throws java.io.IOException
createFlag
- booleanjava.io.IOException
public abstract int readFile(byte[] buf, int len, int pos, long fileOff) throws java.io.IOException
buf
- byte[]len
- intpos
- intfileOff
- longjava.io.IOException
public abstract void writeFile(byte[] buf, int len, int pos, long fileOff) throws java.io.IOException
buf
- byte[] buffer to writelen
- number of bytes to write from the bufferpos
- offset within the buffer to writefileOff
- long offset within the file to write.java.io.IOException
public abstract long seekFile(long pos, int typ) throws java.io.IOException
pos
- longtyp
- intjava.io.IOException
public abstract void flushFile() throws java.io.IOException
java.io.IOException
public abstract void truncateFile(long siz) throws java.io.IOException
siz
- longjava.io.IOException
public abstract void closeFile() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public boolean allowsOpenCloseViaNetworkFile()
public boolean isForce()
public void setForce(boolean force)
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.