|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.waldheinz.fs.util.FileDisk
public final class FileDisk
This is a BlockDevice
that uses a File
as it's backing store.
Field Summary | |
---|---|
static int |
BYTES_PER_SECTOR
The number of bytes per sector for all FileDisk instances. |
Constructor Summary | |
---|---|
FileDisk(File file,
boolean readOnly)
Creates a new instance of FileDisk for the specified
File . |
Method Summary | |
---|---|
void |
close()
Closes this BlockDevice . |
static FileDisk |
create(File file,
long size)
Creates a new FileDisk of the specified size. |
void |
flush()
Flushes data in caches to the actual storage. |
int |
getSectorSize()
Returns the size of a sector on this device. |
long |
getSize()
Gets the total length of this device in bytes. |
boolean |
isClosed()
Checks if this device was already closed. |
boolean |
isReadOnly()
Checks if this BlockDevice is read-only. |
void |
read(long devOffset,
ByteBuffer dest)
Read a block of data from this device. |
void |
write(long devOffset,
ByteBuffer src)
Writes a block of data to this device. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BYTES_PER_SECTOR
FileDisk
instances.
Constructor Detail |
---|
public FileDisk(File file, boolean readOnly) throws FileNotFoundException
FileDisk
for the specified
File
.
file
- the file that holds the disk contentsreadOnly
- if the file should be opened in read-only mode, which
will result in a read-only FileDisk
instance
FileNotFoundException
- if the specified file does not existisReadOnly()
Method Detail |
---|
public static FileDisk create(File file, long size) throws IOException
FileDisk
of the specified size. The
FileDisk
returned by this method will be writable.
file
- the file to hold the FileDisk
contentssize
- the size of the new FileDisk
FileDisk
instance
IOException
- on error creating the FileDisk
public long getSize() throws IOException
BlockDevice
getSize
in interface BlockDevice
IOException
- on error getting the size of this devicepublic void read(long devOffset, ByteBuffer dest) throws IOException
BlockDevice
read
in interface BlockDevice
devOffset
- the byte offset where to read the data fromdest
- the destination buffer where to store the data read
IOException
- on read errorpublic void write(long devOffset, ByteBuffer src) throws IOException
BlockDevice
write
in interface BlockDevice
devOffset
- the byte offset where to store the datasrc
- the source ByteBuffer
to write to the device
IOException
- on write errorBlockDevice.isReadOnly()
public void flush() throws IOException
BlockDevice
flush
in interface BlockDevice
IOException
- on write errorpublic int getSectorSize()
BlockDevice
getSectorSize
in interface BlockDevice
public void close() throws IOException
BlockDevice
BlockDevice
. No methods of this device may be
accesses after this method was called.
close
in interface BlockDevice
IOException
- on error closing this deviceBlockDevice.isClosed()
public boolean isClosed()
BlockDevice
isClosed
in interface BlockDevice
public boolean isReadOnly()
BlockDevice
BlockDevice
is read-only.
isReadOnly
in interface BlockDevice
BlockDevice
is read-only
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |