Previous: Turbo3, Up: GPC Units

6.15.21 BP compatibility: WinDos

The following listing contains the interface of the WinDos unit.

This is a portable implementation of most routines from BP's WinDos unit. A few routines that are Dos – or even IA32 real mode – specific, are only available if __BP_UNPORTABLE_ROUTINES__ is defined, BP Incompatibilities.

The same functionality and much more is available in the Run Time System, Run Time System. The RTS routines usually have different names and/or easier and less limiting interfaces (e.g. ReadDir etc. vs. FindFirst etc.), and are often more efficient.

Therefore, using this unit is not recommended in newly written programs.

     { Mostly BP compatible portable WinDos unit
       This unit supports most, but not all, of the routines and
       declarations of BP's WinDos unit.
       - The procedures GetIntVec and SetIntVec are not supported since
         they make only sense for Dos real-mode programs (and GPC
         compiled programs do not run in real-mode, even on IA32 under
         Dos). The procedures Intr and MsDos are only supported under
         DJGPP if __BP_UNPORTABLE_ROUTINES__ is defined (with the
         -D__BP_UNPORTABLE_ROUTINES__ option). A few other routines are
         also only supported with this define, but on all platforms (but
         they are crude hacks, that's why they are not supported without
         this define).
       - The internal structure of file variables (TFileRec and TTextRec)
         is different in GPC. However, as far as TFDDs are concerned,
         there are other ways to achieve the same in GPC, see the GPC
       Copyright (C) 1998-2005 Free Software Foundation, Inc.
       Author: Frank Heckenbach <>
       This file is part of GNU Pascal.
       GNU Pascal is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published
       by the Free Software Foundation; either version 2, or (at your
       option) any later version.
       GNU Pascal is distributed in the hope that it will be useful, but
       WITHOUT ANY WARRANTY; without even the implied warranty of
       General Public License for more details.
       You should have received a copy of the GNU General Public License
       along with GNU Pascal; see the file COPYING. If not, write to the
       Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
       02111-1307, USA.
       As a special exception, if you link this file with files compiled
       with a GNU compiler to produce an executable, this does not cause
       the resulting executable to be covered by the GNU General Public
       License. This exception does not however invalidate any other
       reasons why the executable file might be covered by the GNU
       General Public License. }
     {$gnu-pascal,I-,maximum-field-alignment 0}
     {$if __GPC_RELEASE__ < 20030412}
     {$error This unit requires GPC release 20030412 or newer.}
     module WinDos;
     export WinDos = all (FCarry, FParity, FAuxiliary, FZero, FSign,
                          DosError, GetDate, GetTime, GetCBreak,
                          GetVerify, SetVerify, DiskFree, DiskSize,
                          GetFAttr, SetFAttr, GetFTime, SetFTime,
                          UnpackTime, PackTime,
                          {$ifdef __BP_UNPORTABLE_ROUTINES__}
                          {$ifdef __GO32__}
                          Intr, MsDos,
                          DosVersion, SetDate, SetTime,
                          CStringGetEnv => GetEnvVar);
     import GPC (MaxLongInt => GPC_Orig_MaxLongInt);
            Dos (FindFirst => Dos_FindFirst,
                 FindNext  => Dos_FindNext,
                 FindClose => Dos_FindClose);
       { File attribute constants }
       faReadOnly  = ReadOnly;
       faHidden    = Hidden;    { set for dot files except . and .. }
       faSysFile   = SysFile;   { not supported }
       faVolumeID  = VolumeID;  { not supported }
       faDirectory = Directory;
       faArchive   = Archive;   { means: not executable }
       faAnyFile   = AnyFile;
       { Maximum file name component string lengths }
       fsPathName  = 79;
       fsDirectory = 67;
       fsFileName  = 8;
       fsExtension = 4;
       { FileSplit return flags }
       fcExtension = 1;
       fcFileName  = 2;
       fcDirectory = 4;
       fcWildcards = 8;
       PTextBuf = ^TTextBuf;
       TTextBuf = TextBuf;
       { Search record used by FindFirst and FindNext }
       TSearchRec = record
         Fill: SearchRecFill;
         Attr: Byte8;
         Time, Size: LongInt;
         Name: {$ifdef __BP_TYPE_SIZES__}
               packed array [0 .. 12] of Char
         Reserved: SearchRec
       { Date and time record used by PackTime and UnpackTime }
       TDateTime = DateTime;
       { 8086 CPU registers -- only used by the unportable Dos routines }
       TRegisters = Registers;
     { FindFirst and FindNext are quite inefficient since they emulate
       all the brain-dead Dos stuff. If at all possible, the standard
       routines OpenDir, ReadDir and CloseDir (in the GPC unit) should be
       used instead. }
     procedure FindFirst (Path: PChar; Attr: Word; var SR: TSearchRec);
     procedure FindNext  (var SR: TSearchRec);
     procedure FindClose (var SR: TSearchRec);
     function  FileSearch (Dest, FileName, List: PChar): PChar;
     function  FileExpand (Dest, FileName: PChar): PChar;
     function  FileSplit (Path, Dir, BaseName, Ext: PChar) = Res: Word;
     function  GetCurDir (Dir: PChar; Drive: Byte): PChar;
     procedure SetCurDir (Dir: PChar);
     procedure CreateDir (Dir: PChar);
     procedure RemoveDir (Dir: PChar);
     function  GetArgCount: Integer;
     function  GetArgStr (Dest: PChar; ArgIndex: Integer; MaxLen: Word):