|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.waldheinz.fs.util.RamDisk
public final class RamDisk
A BlockDevice
that lives entirely in heap memory. This is basically
a RAM disk. A RamDisk
is always writable.
Field Summary | |
---|---|
static int |
DEFAULT_SECTOR_SIZE
The default sector size for RamDisk s. |
Constructor Summary | |
---|---|
RamDisk(int size)
Creates a new instance of RamDisk of this specified
size and using the DEFAULT_SECTOR_SIZE . |
|
RamDisk(int size,
int sectorSize)
Creates a new instance of RamDisk of this specified
size and sector size |
Method Summary | |
---|---|
void |
close()
Closes this BlockDevice . |
void |
flush()
Flushes data in caches to the actual storage. |
ByteBuffer |
getBuffer()
Returns a slice of the ByteBuffer that is used by this
RamDisk as it's backing store. |
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()
Returns always false , as a RamDisk is always writable. |
void |
read(long devOffset,
ByteBuffer dest)
Read a block of data from this device. |
static RamDisk |
readGzipped(File f)
Reads a GZIP compressed file into a new RamDisk instance. |
static RamDisk |
readGzipped(InputStream in)
Reads a GZIP compressed disk image from the specified input stream and returns a RamDisk holding the decompressed image. |
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 DEFAULT_SECTOR_SIZE
RamDisk
s.
Constructor Detail |
---|
public RamDisk(int size)
RamDisk
of this specified
size and using the DEFAULT_SECTOR_SIZE
.
size
- the size of the new block devicepublic RamDisk(int size, int sectorSize)
RamDisk
of this specified
size and sector size
size
- the size of the new block devicesectorSize
- the sector size of the new block deviceMethod Detail |
---|
public static RamDisk readGzipped(InputStream in) throws IOException
RamDisk
holding the decompressed image.
in
- the stream to read the disk image from
RamDisk
IOException
- on read or decompression errorpublic static RamDisk readGzipped(File f) throws FileNotFoundException, IOException
RamDisk
instance.
f
- the file to read
FileNotFoundException
- if the specified file does not exist
IOException
- on read errorpublic long getSize()
BlockDevice
getSize
in interface BlockDevice
public 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 ByteBuffer getBuffer()
ByteBuffer
that is used by this
RamDisk
as it's backing store. The returned buffer will be
live (reflecting any changes made through the
method
, but read-only.
RamDisk
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()
false
, as a RamDisk
is always writable.
isReadOnly
in interface BlockDevice
false
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |