| Class RawFile (unit ODFileUnit) |
TObject
RawFile implements simple binary file with seeking & locking abilities. It is used to implement the other file classes.
| Constructors |
constructor Create;| Functions |
procedure Close;
destructor Destroy;
function FilePosition : integer;Get current position.
function Lock( pos, len : integer ) : boolean;Lock a range of bytes
procedure Open( const fname : string;
omode : FileOpenMode;
smode : FileShareMode;
copts : FileCreateOption );
function Read( buf : pointer;
nbytes : integer ) : integer;
function Seek( moveby : integer; from : FileSeekFrom ) : integer;Seek in file, returning new position.
procedure Unlock( pos, len : integer );
procedure Write( buf : pointer;
nbytes : integer );
procedure Error( const msg : string );RawFile error messaging
| Properties |
property FileName : string
property IsOpen : boolean| Events |
| Variables |
mFile : FileHandle;
mFileName : string;
mIsOpen : boolean;| Constructors |
constructor Create;------------------------------------------------------------------------------ RawFile methods ------------------------------------------------------------------------------ Create new RawFile
| Functions |
procedure Close;Close the file. It is always safe to call Close, even on an already closed file.
Close RawFile
destructor Destroy;Destroy RawFile, closing disk image first.
function FilePosition : integer;Return current read/write position in file
Get current position. This involves seeking to end of file & then back again and could therefore be slow.
function Lock( pos, len : integer ) : boolean;Perform region locking/unlocking
Lock a range of bytes
procedure Open( const fname : string;
omode : FileOpenMode;
smode : FileShareMode;
copts : FileCreateOption );Open a file, possibly creating it. See above for the various modes.
Open RawFile. Most of this is mapping my modes onto Windows modes. Calling this on an already open file will Close & then re-open it.
function Read( buf : pointer;
nbytes : integer ) : integer;Read nbytes from file into buffer pointed to by buf. Returns actual number of bytes read, which may be less than nbytes. If the number of bytes read is zero, then the end of file has been reached.
Read bytes from file
function Seek( moveby : integer; from : FileSeekFrom ) : integer;Seek in a file
Seek in file, returning new position. Raises exception if seek fails.
procedure Unlock( pos, len : integer );Unlock a range of bytesa
procedure Write( buf : pointer;
nbytes : integer );Write nbytes to file from buffer pointed to by buf.
Write bytes to file
procedure Error( const msg : string );is it open?
RawFile error messaging
| Properties |
property FileName : stringAccessors for file name and open state
property IsOpen : boolean| Events |
| Variables |
mFile : FileHandle;
mFileName : string;windows file handle
mIsOpen : boolean;full name of file