file types

File types are represented as records. Typed files and untyped files are represented as a fixed record:

   filerec = packed record
     handle    : longint;
     mode      : longint;
     recsize   : longint;
     _private  : array[1..32] of byte;
     userdata  : array[1..16] of byte;
     name      : array[0..255] of char;
   End;

Text files are described using the following record:

   TextBuf = array[0..255] of char;
   textrec = packed record
     handle    : longint;
     mode      : longint;
     bufsize   : longint;
     _private  : longint;
     bufpos    : longint;
     bufend    : longint;
     bufptr    : ^textbuf;
     openfunc  : pointer;
     inoutfunc : pointer;
     flushfunc : pointer;
     closefunc : pointer;
     userdata  : array[1..16] of byte;
     name      : array[0..255] of char;
     buffer    : textbuf;
   End;
handle
The handle field returns the file handle (if the file is opened), as returned by the operating system.
mode
The mode field can take one of several values. When it is fmclosed, then the file is closed, and the handle field is invalid. When the value is equal to fminput, it indicates that the file is opened for read only access. fmoutput indicates write only access, and the fminout indicates read-write access to the file.
name
The name field is a null terminated character string representing the name of the file.
userdata
The userdata field is never used by Free Pascal, and can be used for special purposes by software developpers.