de.waldheinz.fs
Interface FsFile

All Superinterfaces:
FsObject
All Known Implementing Classes:
FatFile

public interface FsFile
extends FsObject

A FsFile is a representation of a single block of bytes on a filesystem. It is comparable to an inode in Unix. An FsFile does not have any knowledge of who is using this file. It is also possible that the system uses a single FsFile instance to create two inputstream's for two different principals.

Author:
Ewout Prangsma <epr at jnode.org>

Method Summary
 void flush()
          Flush any possibly cached data to the disk.
 long getLength()
          Gets the length (in bytes) of this file.
 void read(long offset, ByteBuffer dest)
          Reads from this file into the specified ByteBuffer.
 void setLength(long length)
          Sets the length of this file.
 void write(long offset, ByteBuffer src)
          Writes to this file taking the data to write from the specified ByteBuffer.
 
Methods inherited from interface de.waldheinz.fs.FsObject
isReadOnly, isValid
 

Method Detail

getLength

long getLength()
Gets the length (in bytes) of this file.

Returns:
the file size

setLength

void setLength(long length)
               throws IOException
Sets the length of this file.

Parameters:
length - the new length of this file
Throws:
IOException - on error updating the file size

read

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.

Parameters:
offset - the offset into the file where to start reading
dest - the destination buffer where to put the bytes that were read
Throws:
IOException - on read error

write

void write(long offset,
           ByteBuffer src)
           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.

Parameters:
offset - the offset into the file where the first byte will be written
src - the source buffer to read the data from
Throws:
ReadOnlyException - if the file is read-only
IOException - on write error

flush

void flush()
           throws IOException
Flush any possibly cached data to the disk.

Throws:
IOException - on error flushing


Copyright © 2014. All rights reserved.