Member Functions
The class RWFileManager adds four additional member functions to those of class RWFile. They are:
1. RWoffset allocate(RWspace s);
Allocates s bytes of storage in the file, returning the offset to the start of the allocation.
2. void deallocate(RWoffset t);
Deallocates (frees) the storage space starting at offset t. This space must have been previously allocated by the function allocate().
3. RWOffset endData();
Returns the offset to the last data in the file.
4. RWoffset start();
Returns the offset from the start of the file to the first space ever allocated by RWFileManager, or returns RWNIL if no space has been allocated, which implies that this is a new file. RWNIL is a macro whose actual value is system dependent. Typically, it is -1L.
The statement:
 
RWoffset a = F.allocate(sizeof(double));
uses F of RWFileManager to allocate the space required to store an object with the size of a double, and returns the offset to that space. To write the object to the disk file, you should seek to the allocated location and use Write(). It is an error to read or write to an unallocated location in the file.
It is your responsibility to maintain a record of the offsets necessary to read the stored object. To help you do this, the first allocation ever made by an RWFileManager is considered special and can be returned by member function start() at any time. The RWFileManager will not allow you to deallocate it. This first block will typically hold information necessary to read the remaining data, perhaps the offset of a root node, or the head of a linked-list.