org.garret.perst
Interface IFile

All Known Implementing Classes:
MappedFile, NullFile

public interface IFile

Interface of file. Programmer can provide its own impleentation of this interface, adding such features as support of flash cards, encrypted files,... Implentation of this interface should throw StorageError exception in case of failure


Method Summary
 void close()
          Close file
 long length()
          Length of the file
 boolean lock()
          Lock file
 int read(long pos, byte[] buf)
          Reade data from the file
 void sync()
          Flush all fiels changes to the disk
 void write(long pos, byte[] buf)
          Write data to the file
 

Method Detail

close

void close()
Close file


length

long length()
Length of the file

Returns:
length of file in bytes

lock

boolean lock()
Lock file

Returns:
true if file was successfully locked or locking in not implemented, false if file is locked by some other applciation

read

int read(long pos,
         byte[] buf)
Reade data from the file

Parameters:
pos - offset in the file
buf - array to receive readen data (size is always equal to database page size)
Returns:
number of bytes actually readen

sync

void sync()
Flush all fiels changes to the disk


write

void write(long pos,
           byte[] buf)
Write data to the file

Parameters:
pos - offset in the file
buf - array with data to be writter (size is always equal to database page size)