File Types

File types are represented as records. Typed files and untyped files occupy 332 bytes, which are laid out as follows:

type

TFileRec = packed record Handle: Integer; Mode: word; Flags: word; case Byte of

BufPos: Cardinal;

BufEnd: Cardinal;

BufPtr: PChar;

OpenFunc: Pointer;

InOutFunc: Pointer;

FlushFunc: Pointer;

CloseFunc: Pointer;

UserData: array[1..32] of Byte;

end;

Text files occupy 460 bytes, which are laid out as follows:

type

TTextBuf = array[0..127] of Char; TTextRec = packed record Handle: Integer;

Mode: word;

Flags: word;

BufSize: Cardinal;

BufPos: Cardinal;

BufEnd: Cardinal;

BufPtr: PChar;

OpenFunc: Pointer;

InOutFunc: Pointer;

FlushFunc: Pointer;

CloseFunc: Pointer;

UserData: array[1..32] of Byte;

Buffer: TTextBuf;

end;

Handle contains the file's handle (when the file is open). The Mode field can assume one of the values const fmClosed = $D7B0; fmInput= $D7B1; fmOutput = $D7B2; fmInOut= $D7B3;

where fmClosed indicates that the file is closed, fmlnput and fmOutput indicate a text file that has been reset (fmlnput) or rewritten (fmOutput), fmlnOut indicates a typed or untyped file that has been reset or rewritten. Any other value indicates that the file variable is not assigned (and hence not initialized).

The UserData field is available for user-written routines to store data in.

Name contains the file name, which is a sequence of characters terminated by a null character (#0).

For typed files and untyped files, RecSize contains the record length in bytes, and the Private field is unused but reserved.

For text files, BufPtr is a pointer to a buffer of BufSize bytes, BufPos is the index of the next character in the buffer to read or write, and BufEnd is a count of valid characters in the buffer. OpenFunc, InOutFunc, FlushFunc, and CloseFunc are pointers to the I/O routines that control the file; see Device functions. Flags determines the line break style as follows:

bit 0 clearLF line breaks bit 0 set CRLF line breaks

All other Flags bits are reserved for future use.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment