| Class RandomAccessFile (unit ODFileUnit) |
TObject
This class supports random access to fixed-sized records.
| Constructors |
constructor Create;------------------------------------------------------------------------------ RandomAccessFile methods.
| Functions |
procedure Close;usual stuff
destructor Destroy;
procedure Extend( count : integer );
function FileName : string;
function IsOpen : boolean;
function LockRecord( recno : integer ) : boolean;Record locking
procedure Open( const fname : string;
recsize : integer;
omode : FileOpenMode;
smode : FileShareMode;
copts : FileCreateOption );
function ReadNextRecord( rec : pointer ) : boolean;
function ReadRecord( rec : pointer; recno : integer ) : boolean;
function RecordCount : integer;
procedure UnlockRecord( recno : integer );
procedure WriteRecord( rec : pointer; recno : integer );| Properties |
| Events |
| Variables |
mFile : RawFile;
mRecSize : integer;| Constructors |
constructor Create;record size
------------------------------------------------------------------------------ RandomAccessFile methods. RawFile class does most of the work. ------------------------------------------------------------------------------ constructor creates rawfile
| Functions |
procedure Close;Usual stuff
usual stuff
destructor Destroy;
procedure Extend( count : integer );Extend the file by count records. The new records will contain garbage.
extend file by count records
function FileName : string;
function IsOpen : boolean;
function LockRecord( recno : integer ) : boolean;Record locking
Record locking
procedure Open( const fname : string;
recsize : integer;
omode : FileOpenMode;
smode : FileShareMode;
copts : FileCreateOption );Open or create a RandomAccessFile. The RecSize parameter indicates the size of the recoord in the file. This is not stored in the file itself.
Mode mapping not necessary, as we pass things thru to RawFile
function ReadNextRecord( rec : pointer ) : boolean;read the next record sequentially. The first call to this method must be preceded with a call to ReadRecord.
read next record. Should have made som positioning call (like REadRecord) before calling this
function ReadRecord( rec : pointer; recno : integer ) : boolean;Read a record. If the record does not exist, the function returns false.
read a record
function RecordCount : integer;Return the number of recordsin the file.
Return number of records. This causes several seeks, so may be slow
procedure UnlockRecord( recno : integer );and unlocking
procedure WriteRecord( rec : pointer; recno : integer );write a record at record number recno, which must be greater or equal to zero. A record number greater than that of the last record will extend the file.
write record. If record number higher than current highest, the call to Seek will extend the file
| Properties |
| Events |
| Variables |
mFile : RawFile;
mRecSize : integer;RawFile implementation