2.1 Types, Variables, Constants

Constants

The DOS unit implements the following constants:
File attributes

The File Attribute constants are used in FindFirst (86), FindNext (87) to determine what type of special file to search for in addition to normal files. These flags are also used in the SetFAttr (98) and GetFAttr (90) routines to set and retrieve attributes of files. For their definitions consult table (2.1).



Table 2.1: Possible file attributes



Constant Description Value



readonly Read only file $01
hidden Hidden file $02
sysfile System file $04
volumeid Volume label $08
directory Directory $10
archive Archive $20
anyfile Any of the above special files $3F




fmXXXX

These constants are used in the Mode field of the TextRec record. Gives information on the filemode of the text I/O. For their definitions consult table (2.2).



Table 2.2: Possible mode constants



Constant Description Value



fmclosed File is closed $D7B0
fminput File is read only $D7B1
fmoutput File is write only $D7B2
fminout File is read and write $D7B3




Other

The following constants are not portable, and should not be used. They are present for compatibility only.

   {Bitmasks for CPU Flags}
   fcarry =     $0001;
   fparity =    $0004;
   fauxiliary = $0010;
   fzero =      $0040;
   fsign =      $0080;
   foverflow  = $0800;

Types

The following string types are defined for easy handling of filenames :
   ComStr  = String[255];   { For command-lines }
   PathStr = String[255];   { For full path for file names }
   DirStr  = String[255];   { For Directory and (DOS) drive string }
   NameStr = String[255];   { For Name of file }
   ExtStr  = String[255];   { For Extension of file }
   SearchRec = Packed Record
     Fill : array[1..21] of byte;
     { Fill replaced with declarations below, for Linux}
     Attr : Byte; {attribute of found file}
     Time : LongInt; {last modify date of found file}
     Size : LongInt; {file size of found file}
     Reserved : Word; {future use}
     Name : String[255]; {name of found file}
     SearchSpec: String[255]; {search pattern}
     NamePos: Word; {end of path, start of name position}
     End;
Under LINUX, the Fill array is replaced with the following:
     SearchNum: LongInt; {to track which search this is}
     SearchPos: LongInt; {directory position}
     DirPtr: LongInt; {directory pointer for reading directory}
     SearchType: Byte;  {0=normal, 1=open will close}
     SearchAttr: Byte; {attribute we are searching for}
     Fill: Array[1..07] of Byte; {future use}
This is because the searching meachanism on Unix systems is substantially different from DOS’s, and the calls have to be mimicked.
 const
   filerecnamelength = 255;
 type
   FileRec = Packed Record
     Handle,
     Mode,
     RecSize   : longint;
     _private  : array[1..32] of byte;
     UserData  : array[1..16] of byte;
     name      : array[0..filerecnamelength] of char;
   End;
FileRec is used for internal representation of typed and untyped files. Text files are handled by the following types :
 const
   TextRecNameLength = 256;
   TextRecBufSize    = 256;
 type
   TextBuf = array[0..TextRecBufSize-1] of char;
   TextRec = Packed Record
     Handle,
     Mode,
     bufsize,
     _private,
     bufpos,
     bufend    : longint;
     bufptr    : ^textbuf;
     openfunc,
     inoutfunc,
     flushfunc,
     closefunc : pointer;
     UserData  : array[1..16] of byte;
     name      : array[0..textrecnamelength-1] of char;
     buffer    : textbuf;
   End;
Remark that this is not binary compatible with the Turbo Pascal definition of TextRec, since the sizes of the different fields are different.
     Registers = record
       case i : integer of
         0 : (ax,f1,bx,f2,cx,f3,dx,f4,bp,f5,si,
              f51,di,f6,ds,f7,es,f8,flags,fs,gs : word);
         1 : (al,ah,f9,f10,bl,bh,f11,f12,
              cl,ch,f13,f14,dl,dh : byte);
         2 : (eax,  ebx,  ecx,  edx,  ebp,  esi,  edi : longint);
         End;
The registers type is used in the MSDos call.
   DateTime = record
     Year: Word;
     Month: Word;
     Day: Word;
     Hour: Word;
     Min: Word;
     Sec: word;
     End;
The DateTime type is used in PackTime (96) and UnPackTime (100) for setting/reading file times with GetFTime (92) and SetFTime (98).

Variables

     DosError : integer;
The DosError variable is used by the procedures in the DOS unit to report errors. It can have the following values :
2 File not found.
3 path not found.
5 Access denied.
6 Invalid handle.
8 Not enough memory.
10 Invalid environment.
11 Invalid format.
18 No more files.
Other values are possible, but are not documented.