moka.io
Class VatEntry

java.lang.Object
  extended bymoka.lang.Object
      extended bymoka.io.VatEntry

public class VatEntry
extends Object

Provides methods to deal with the TIOS' variable Allocation table (VAT) and offers a full random access to its data. This class aims to provide a faster and more efficient way to access storage than File class. However, you must allocate the space needed for data storage manually. Also, you must invoke allocHandle() to create a new file (otherwise the instance of VatEntry will try to refer an existing VAT entry).

Since:
MDK2.21

Constructor Summary
VatEntry(File f)
          Creates a new VatEntry instance by using the given File.
VatEntry(String name)
          Creates a new VatEntry instance by using the given name string.
 
Method Summary
 byte[] allocHandle(ulong size)
          Creates a new entry in the VAT, and associates it with this VatEntry.
 void assign(String name)
          Associates a new VAT entry with this VatEntry instance, after releasing the VatEntry.
 boolean delete()
          Deletes the variable denoted by this VatEntry instance.
 byte[] derefHandle()
          Returns a pointer to the dereferenced handle associated with this VatEntry.
 boolean exists()
          Tests whether the variable denoted by this VatEntry instance exists.
 void finalize()
          Frees the memory of system ressources used by this VatEntry object.
 boolean mkdir()
          Creates the directory named by this VatEntry instance.
 byte[] reallocHandle(ulong size)
          Reallocates the user data space associated with the VatEntry.
 void release()
          Releases the VatEntry.
 boolean renameTo(String dest)
          Renames the variable denoted by this VatEntry instance.
 boolean rmdir()
          Removes the directory named by this VatEntry instance including all files in it.
 
Methods inherited from class moka.lang.Object
equals, getClassName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VatEntry

public VatEntry(String name)
Creates a new VatEntry instance by using the given name string. If the name string object risk to be used later, use a copy of the string object instead of the original.

Parameters:
name - The name of the VAT entry

VatEntry

public VatEntry(File f)
Creates a new VatEntry instance by using the given File. The File will be finalized.

Parameters:
f - The symbolic path name of the VAT entry
Method Detail

exists

public boolean exists()
Tests whether the variable denoted by this VatEntry instance exists.

Returns:
true if and only if the variable denoted by this VatEntry instance exists; false otherwise

delete

public boolean delete()
Deletes the variable denoted by this VatEntry instance.

Returns:
true if and only if the variable is successfully deleted; false otherwise

mkdir

public boolean mkdir()
Creates the directory named by this VatEntry instance.

Returns:
true if and only if the directory was created; false otherwise

rmdir

public boolean rmdir()
Removes the directory named by this VatEntry instance including all files in it.

Returns:
true if and only if the directory was removed; false otherwise

renameTo

public boolean renameTo(String dest)
Renames the variable denoted by this VatEntry instance. If the dest string object risk to be used later, use a copy of the string object instead of the original. Even if the operation is successful, this VatEntry instance pathname will still refer to the previous VAT entry.

Parameters:
dest - The new abstract pathname for the named variable
Returns:
true if and only if the renaming succeeded; false otherwise

assign

public void assign(String name)
Associates a new VAT entry with this VatEntry instance, after releasing the VatEntry.

Parameters:
name - The name of the entry to assign to this VatEntry instance.

derefHandle

public byte[] derefHandle()
Returns a pointer to the dereferenced handle associated with this VatEntry. If the handle is not already locked, The associated handle will be locked until the VatEntry is released or finalized.

Returns:
The dereferenced handle associated with the VAT entry. null in case of error.

allocHandle

public byte[] allocHandle(ulong size)
Creates a new entry in the VAT, and associates it with this VatEntry. Will allocate size bytes of space for user data. The associated handle will be locked until the VatEntry is released or finalized.

Parameters:
size - The size needed for user data.
Returns:
The dereferenced handle associated with the new VAT entry. null in case of error.

reallocHandle

public byte[] reallocHandle(ulong size)
Reallocates the user data space associated with the VatEntry. Will reallocate the space for user data to size bytes. The associated handle will be locked until the VatEntry is released or finalized. One of the two initial acces method (derefHandle() or allocHandle()) must have been called previously for this method to work properly. Also, keep in mind that the behavior is undefined if the handle have been locked by another entity than this VatEntry, because this method will unlock the handle, reallocate it and relock it.

Parameters:
size - The size needed for user data.
Returns:
The dereferenced handle associated with the VAT entry. null in case of error.

release

public void release()
Releases the VatEntry. Will unlock the handle only if this instance locked it during its operation (will be the case if the handle was not locked before derefHandle() or allocHandle() was called).


finalize

public void finalize()
Frees the memory of system ressources used by this VatEntry object. The handle is released before the method returns (see release()).

Overrides:
finalize in class Object