|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.waldheinz.fs.AbstractFsObject
de.waldheinz.fs.fat.FatFile
public final class FatFile
The in-memory representation of a single file (chain of clusters) on a FAT file system.
Method Summary | |
---|---|
void |
flush()
Has no effect besides possibly throwing an ReadOnlyException . |
long |
getLength()
Returns the length of this file in bytes. |
void |
read(long offset,
ByteBuffer dest)
Reads from this file into the specified ByteBuffer .
Unless this file is read-ony , this method also
updates the "last accessed" field in the directory entry that is
associated with this file. |
void |
setLength(long length)
Sets the size (in bytes) of this file. |
String |
toString()
Returns a human-readable string representation of this FatFile ,
mainly for debugging purposes. |
void |
write(long offset,
ByteBuffer srcBuf)
Writes to this file taking the data to write from the specified ByteBuffer .
If the data to be written extends beyond the current
length of this file, an attempt is made to
grow the file so that the data will fit. |
Methods inherited from class de.waldheinz.fs.AbstractFsObject |
---|
checkValid, checkWritable, invalidate, isReadOnly, isValid |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.waldheinz.fs.FsObject |
---|
isReadOnly, isValid |
Method Detail |
---|
public long getLength()
getLength
in interface FsFile
public void setLength(long length) throws ReadOnlyException, IOException
writing
to the file will grow
it automatically if needed, this method is mainly usefull for truncating
a file.
setLength
in interface FsFile
length
- the new length of the file in bytes
ReadOnlyException
- if this file is read-only
IOException
- on error updating the file sizepublic void read(long offset, ByteBuffer dest) throws IOException
Reads from this file into the specified ByteBuffer
. The
first byte read will be put into the buffer at it's
position
, and the number of bytes read
will equal the buffer's remaining
bytes.
Unless this file is read-ony
, this method also
updates the "last accessed" field in the directory entry that is
associated with this file.
read
in interface FsFile
offset
- the offset into the file where to start readingdest
- the destination buffer where to put the bytes that were read
IOException
- on read errorFatDirectoryEntry.setLastAccessed(long)
public void write(long offset, ByteBuffer srcBuf) throws ReadOnlyException, IOException
Writes to this file taking the data to write from the specified
ByteBuffer
. This method will read the buffer's
remaining
bytes starting at it's
position
.
If the data to be written extends beyond the current
length
of this file, an attempt is made to
grow
the file so that the data will fit.
Additionally, this method updates the "last accessed" and "last modified"
fields on the directory entry that is associated with this file.
write
in interface FsFile
offset
- the offset into the file where the first byte will be
writtensrcBuf
- the source buffer to read the data from
ReadOnlyException
- if the file is read-only
IOException
- on write errorpublic void flush() throws ReadOnlyException
ReadOnlyException
. To
make sure that all data is written out to disk use the
FatFileSystem.flush()
method.
flush
in interface FsFile
ReadOnlyException
- if this FatFile
is read-onlypublic String toString()
FatFile
,
mainly for debugging purposes.
toString
in class Object
FatFile
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |