-
Declaration:
- Procedure AddDisk (Const S : String);
-
Description:
- AddDisk adds a filename S to the internal list of disks. It is implemented for systems which do not
use DOS type drive letters. This list is used to determine which disks to use in the
DiskFree (80) and DiskSize (81) calls. The DiskFree (80) and DiskSize (81) functions
need a file on the specified drive, since this is required for the statfs system call. The
names are added sequentially. The dos initialization code presets the first three disks
to:
- '.' for the current drive,
- '/fd0/.' for the first floppy-drive (linux only).
- '/fd1/.' for the second floppy-drive (linux only).
- '/' for the first hard disk.
The first call to AddDisk will therefore add a name for the second harddisk, The second call for the
third drive, and so on until 23 drives have been added (corresponding to drives 'D:' to
'Z:')
-
Errors:
- None
-
See also:
- DiskFree (80), DiskSize (81)
-
Declaration:
- Function DiskFree (Drive: byte) : int64;
-
Description:
-
DiskFree returns the number of free bytes on a disk. The parameter Drive indicates which
disk should be checked. This parameter is 1 for floppy a:, 2 for floppy b:, etc. A value of 0
returns the free space on the current drive.
For unix only:
The diskfree and disksize functions need a file on the specified drive, since this is required for
the statfs system call. These filenames are set in the initialization of the dos unit, and have been
preset to :
- '.' for the current drive,
- '/fd0/.' for the first floppy-drive (linux only).
- '/fd1/.' for the second floppy-drive (linux only).
- '/' for the first hard disk.
There is room for 1-26 drives. You can add a drive with the AddDisk (80) procedure. These settings
can be coded in dos.pp, in the initialization part.
-
Errors:
- -1 when a failure occurs, or an invalid drive number is given.
-
See also:
- DiskSize (81), AddDisk (80)
Listing: dosex/ex6.pp
-
Declaration:
- Function DiskSize (Drive: byte) : int64;
-
Description:
-
DiskSize returns the total size (in bytes) of a disk. The parameter Drive indicates which
disk should be checked. This parameter is 1 for floppy a:, 2 for floppy b:, etc. A value of 0
returns the size of the current drive.
For unix only:
The diskfree and disksize functions need a file on the specified drive, since this is required for
the statfs system call. These filenames are set in the initialization of the dos unit, and have been
preset to :
- '.' for the current drive,
- '/fd0/.' for the first floppy-drive (linux only).
- '/fd1/.' for the second floppy-drive (linux only).
- '/' for the first hard disk.
There is room for 1-26 drives. You can add a drive with the AddDisk (80) procedure. These settings
can be coded in dos.pp, in the initialization part.
-
Errors:
- -1 when a failure occurs, or an invalid drive number is given.
-
See also:
- DiskFree (80), AddDisk (80)
For an example, see DiskFree (80).
-
Declaration:
- Function DosExitCode : Word;
-
Description:
-
DosExitCode contains (in the low byte) the exit-code of a program executed with the Exec
call.
-
Errors:
- None.
-
See also:
- Exec (85)
Listing: dosex/ex5.pp
-
Declaration:
- Function DosVersion : Word;
-
Description:
- DosVersion returns the operating system or kernel version. The low byte contains the major
version number, while the high byte contains the minor version number.
-
Portability:
- On systems where versions consists of more then two numbers, only the first two numbers will
be returned. For example Linux version 2.1.76 will give you DosVersion 2.1. Some operating
systems, such as FREEBSD, do not have system calls to return the kernel version, in that
case a value of 0 will be returned.
-
Errors:
- None.
-
See also:
-
Listing: dosex/ex1.pp
-
Declaration:
- Function EnvCount : longint;
-
Description:
- EnvCount returns the number of environment variables.
-
Errors:
- None.
-
See also:
- EnvStr (84), Dos:GetEnv (90)
-
Declaration:
- Function EnvStr (Index: integer) : string;
-
Description:
-
EnvStr returns the Index-th Name=Value pair from the list of environment variables. The
index of the first pair is zero.
-
Errors:
- The length is limited to 255 characters.
-
See also:
- EnvCount (84), Dos:GetEnv (90)
Listing: dosex/ex13.pp
-
Declaration:
- Procedure Exec (const Path: pathstr; const ComLine: comstr);
-
Description:
-
Exec executes the program in Path, with the options given by ComLine. After the program
has terminated, the procedure returns. The Exit value of the program can be consulted with
the DosExitCode function.
-
Errors:
- Errors are reported in DosError.
-
See also:
- DosExitCode (82)
For an example, see DosExitCode (82)
-
Declaration:
- Function FExpand (const path: pathstr) : pathstr;
-
Description:
-
FExpand takes its argument and expands it to a complete filename, i.e. a filename starting
from the root directory of the current drive, prepended with the drive-letter or volume name
(when supported).
-
Portability:
- On case sensitive file systems (such as UNIX and LINUX), the resulting name is left as it is,
otherwise it is converted to uppercase.
-
Errors:
- FSplit (88)
-
See also:
Listing: dosex/ex5.pp
-
Declaration:
- Procedure FindClose (Var F: SearchRec);
-
Description:
- FindClose frees any resources associated with the search record F.
This call is needed to free any internal resources allocated by the FindFirst (753) or FindNext
(754) calls.
The LINUX implementation of the DOS unit therefore keeps a table of open directories, and
when the table is full, closes one of the directories, and reopens another. This system is
adequate but slow if you use a lot of searchrecs. So, to speed up the findfirst/findnext
system, the FindClose call was implemented. When you don’t need a searchrec any more,
you can tell this to the DOS unit by issuing a FindClose call. The directory which is kept
open for this searchrec is then closed, and the table slot freed.
-
Portability:
- It is recommended to use the LINUX call Glob when looking for files on LINUX.
-
Errors:
- Errors are reported in DosError.
-
See also:
- Glob (401).
-
Declaration:
- Procedure FindFirst (const Path: pathstr; Attr: word; var F: SearchRec);
-
Description:
-
FindFirst searches the file specified in Path. Normal files, as well as all special files which
have the attributes specified in Attr will be returned.
It returns a SearchRec record for further searching in F. Path can contain the wildcard
characters ? (matches any single character) and * (matches 0 ore more arbitrary characters).
In this case FindFirst will return the first file which matches the specified criteria. If
DosError is different from zero, no file(s) matching the criteria was(were) found.
-
Portability:
- On OS/2, you cannot issue two different FindFirst calls. That is, you must close any
previous search operation with FindClose (86) before starting a new one. Failure to do so will
end in a Run-Time Error 6 (Invalid file handle)
-
Errors:
- Errors are reported in DosError.
-
See also:
- FindNext (87), FindClose (86)
Listing: dosex/ex7.pp
-
Declaration:
- Procedure FindNext (var f: searchRec);
-
Description:
-
FindNext takes as an argument a SearchRec from a previous FindNext call, or a FindFirst
call, and tries to find another file which matches the criteria, specified in the FindFirst call.
If DosError is different from zero, no more files matching the criteria were found.
-
Errors:
- DosError is used to report errors.
-
See also:
- FindFirst (86), FindClose (86)
For an example, see FindFirst (86).
-
Declaration:
- Function FSearch (Path: pathstr; DirList: string) : pathstr;
-
Description:
- FSearch searches the file Path in all directories listed in DirList. The full name of the
found file is returned. DirList must be a list of directories, separated by semi-colons. When
no file is found, an empty string is returned.
-
Portability:
- On UNIX systems, DirList can also be separated by colons, as is customary on those
environments.
-
Errors:
- None.
-
See also:
- FExpand (85)
Listing: dosex/ex10.pp
-
Declaration:
- Procedure FSplit (path: pathstr;
var dir: dirstr; var name: namestr; var ext: extstr);
-
Description:
-
FSplit splits a full file name into 3 parts : A Path, a Name and an extension (in ext.) The
extension is taken to be all letters after the last dot (.). For DOS, however, an exception is
made when LFNSupport=False, then the extension is defined as all characters after the first
dot.
-
Errors:
- None.
-
See also:
- FSearch (87)
Listing: dosex/ex12.pp
-
Declaration:
- Procedure GetCBreak (var breakvalue: boolean);
-
Description:
-
GetCBreak gets the status of CTRL-Break checking under DOS and AMIGA. When
BreakValue is false, then DOS only checks for the CTRL-Break key-press when I/O is
performed. When it is set to True, then a check is done at every system call.
-
Portability:
- Under non-DOS and non-AMIGA operating systems, BreakValue always returns True.
-
Errors:
- None
-
See also:
- SetCBreak (97)
-
Declaration:
- Procedure GetDate (var year, month, mday, wday: word);
-
Description:
-
GetDate returns the system’s date. Year is a number in the range 1980..2099.mday is the day
of the month, wday is the day of the week, starting with Sunday as day 0.
-
Errors:
- None.
-
See also:
- GetTime (94),SetDate (97)
Listing: dosex/ex2.pp
-
Declaration:
- Function GetEnv (EnvVar: String) : String;
-
Description:
-
Getenv returns the value of the environment variable EnvVar. When there is no environment
variable EnvVar defined, an empty string is returned.
-
Portability:
- Under some operating systems (such as UNIX), case is important when looking for EnvVar.
-
Errors:
- None.
-
See also:
- EnvCount (84), EnvStr (84)
Listing: dosex/ex14.pp
-
Declaration:
- Procedure GetFAttr (var F; var Attr: word);
-
Description:
-
GetFAttr returns the file attributes of the file-variable f. F can be a untyped or typed file, or of
type Text. f must have been assigned, but not opened. The attributes can be examined with the
following constants :
- ReadOnly
- Hidden
- SysFile
- VolumeId
- Directory
- Archive
Under LINUX, supported attributes are:
- Directory
- ReadOnly if the current process doesn’t have access to the file.
- Hidden for files whose name starts with a dot ('.').
-
Errors:
- Errors are reported in DosError
-
See also:
- SetFAttr (98)
Listing: dosex/ex8.pp
-
Declaration:
- Procedure GetFTime (var F; var Time: longint);
-
Description:
-
GetFTime returns the modification time of a file. This time is encoded and must be decoded
with UnPackTime. F must be a file type, which has been assigned, and opened.
-
Errors:
- Errors are reported in DosError
-
See also:
- SetFTime (98), PackTime (96),UnPackTime (100)
Listing: dosex/ex9.pp
-
Declaration:
- Procedure GetIntVec (IntNo: byte; var Vector: pointer);
-
Description:
-
GetIntVec returns the address of interrupt vector IntNo.
-
Portability:
- This call does nothing, it is present for compatibility only.
-
Errors:
- None.
-
See also:
- SetIntVec (99)
-
Declaration:
- function GetLongName(var p : String) : boolean;
-
Description:
- This function is only implemented in the GO32V2 version of Free Pascal.
GetLongName changes the filename p to a long filename if the DOS call to do this is successful.
The resulting string is the long file name corresponding to the short filename p.
The function returns True if the DOS call was successful, False otherwise.
This function should only be necessary when using the DOS extender under Windows 95
and higher.
-
Errors:
- If the DOS call was not succesfull, False is returned.
-
See also:
- GetShortName (93)
-
Declaration:
- function GetShortName(var p : String) : boolean;
-
Description:
- This function is only implemented in the GO32V2 version of Free Pascal.
GetShortName changes the filename p to a short filename if the DOS call to do this is
successful. The resulting string is the short file name corresponding to the long filename p.
The function returns True if the DOS call was successful, False otherwise.
This function should only be necessary when using the DOS extender under Windows 95
and higher.
-
Errors:
- If the DOS call was not successful, False is returned.
-
See also:
- GetLongName (93)
-
Declaration:
- Procedure GetTime (var hour, minute, second, sec100: word);
-
Description:
-
GetTime returns the system’s time. Hour is a on a 24-hour time scale. sec100 is in hundredth
of a second.
-
Portability:
- Certain operating systems (such as AMIGA), always set the sec100 field to zero.
-
Errors:
- None.
-
See also:
- GetDate (89), SetTime (99)
Listing: dosex/ex3.pp
-
Declaration:
- Procedure GetVerify (var verify: boolean);
-
Description:
-
GetVerify returns the status of the verify flag under DOS. When Verify is True, then DOS
checks data which are written to disk, by reading them after writing. If Verify is False,
then data written to disk are not verified.
-
Portability:
- Under non-DOS systems (excluding OS/2 applications running under vanilla DOS), Verify
is always True.
-
Errors:
- None.
-
See also:
- SetVerify (99)
-
Declaration:
- Procedure Intr (IntNo: byte; var Regs: registers);
-
Description:
-
Intr executes a software interrupt number IntNo (must be between 0 and 255), with
processor registers set to Regs. After the interrupt call returned, the processor registers are
saved in Regs.
-
Portability:
- Under non-DOS operating systems, this call does nothing.
-
Errors:
- None.
-
See also:
- MSDos (96), see the LINUX unit.
-
Declaration:
- Procedure Keep (ExitCode: word);
-
Description:
- Keep terminates the program, but stays in memory. This is used for TSR (Terminate Stay
Resident) programs which catch some interrupt. ExitCode is the same parameter as the Halt
function takes.
-
Portability:
- This call does nothing, it is present for compatibility only.
-
Errors:
- None.
-
See also:
- Halt ()
-
Declaration:
- Procedure MSDos (var regs: registers);
-
Description:
-
MSDos executes an operating system. This is the same as doing a Intr call with the interrupt
number for an os call.
-
Portability:
- Under non-DOS operating systems, this call does nothing. On DOS systems, this calls
interrupt $21.
-
Errors:
- None.
-
See also:
- Intr (95)
-
Declaration:
- Procedure PackTime (var T: datetime; var P: longint);
-
Description:
-
UnPackTime converts the date and time specified in T to a packed-time format which can be
fed to SetFTime.
-
Errors:
- None.
-
See also:
- SetFTime (98), FindFirst (86), FindNext (87), UnPackTime (100)
Listing: dosex/ex4.pp
-
Declaration:
- Procedure SetCBreak (breakvalue: boolean);
-
Description:
-
SetCBreak sets the status of CTRL-Break checking. When BreakValue is false, then DOS
only checks for the CTRL-Break key-press when I/O is performed. When it is set to True,
then a check is done at every system call.
-
Portability:
- Under non-DOS and non-AMIGA operating systems, this call does nothing.
-
Errors:
- None.
-
See also:
- GetCBreak (89)
-
Declaration:
- Procedure SetDate (year,month,day: word);
-
Description:
-
SetDate sets the system’s internal date. Year is a number between 1980 and 2099.
-
Portability:
- On a LINUX machine, there must be root privileges, otherwise this routine will do nothing.
On other UNIX systems, this call currently does nothing.
-
Errors:
- None.
-
See also:
- Dos:GetDate (89), SetTime (99)
-
Declaration:
- Procedure SetFAttr (var F; Attr: word);
-
Description:
-
SetFAttr sets the file attributes of the file-variable F. F can be a untyped or typed file, or of type
Text. F must have been assigned, but not opened. The attributes can be a sum of the following
constants:
- ReadOnly
- Hidden
- SysFile
- VolumeId
- Directory
- Archive
-
Portability:
- Under UNIX like systems (such as LINUX and BEOS) the call exists, but is not implemented, i.e. it
does nothing.
-
Errors:
- Errors are reported in DosError.
-
See also:
- GetFAttr (90)
-
Declaration:
- Procedure SetFTime (var F; Time: longint);
-
Description:
-
SetFTime sets the modification time of a file, this time is encoded and must be encoded with
PackTime. F must be a file type, which has been assigned, and opened.
-
Portability:
- Under UNIX like systems (such as LINUX and BEOS) the call exists, but is not implemented,
i.e. it does nothing.
-
Errors:
- Errors are reported in DosError
-
See also:
- GetFTime (92), PackTime (96),UnPackTime (100)
-
Declaration:
- Procedure SetIntVec (IntNo: byte; Vector: pointer);
-
Description:
- SetIntVec sets interrupt vector IntNo to Vector. Vector should point to an interrupt
procedure.
-
Portability:
- This call does nothing, it is present for compatibility only.
-
Errors:
- None.
-
See also:
- GetIntVec (93)
-
Declaration:
- Procedure SetTime (hour,minute,second,sec100: word);
-
Description:
- SetTime sets the system’s internal clock. The Hour parameter is on a 24-hour time scale.
-
Portability:
- On a LINUX machine, there must be root privileges, otherwise this routine will do nothing.
On other UNIX systems, this call currently does nothing.
-
Errors:
- None.
-
See also:
- Dos:GetTime (94), SetDate (97)
-
Declaration:
- Procedure SetVerify (verify: boolean);
-
Description:
-
SetVerify sets the status of the verify flag under DOS. When Verify is True, then DOS
checks data which are written to disk, by reading them after writing. If Verify is False,
then data written to disk are not verified.
-
Portability:
- Under non-DOS operating systems (excluding OS/2 applications running under vanilla dos),
Verify is always True.
-
Errors:
- None.
-
See also:
- SetVerify (99)
-
Declaration:
- Procedure SwapVectors ;
-
Description:
-
SwapVectors swaps the contents of the internal table of interrupt vectors with the current
contents of the interrupt vectors. This is called typically in before and after an Exec call.
-
Portability:
- Under certain operating systems, this routine may be implemented as an empty stub.
-
Errors:
- None.
-
See also:
- Exec (85), SetIntVec (99)
-
Declaration:
- Procedure UnPackTime (p: longint; var T: datetime);
-
Description:
-
UnPackTime converts the file-modification time in p to a DateTime record. The
file-modification time can be returned by GetFTime, FindFirst or FindNext calls.
-
Errors:
- None.
-
See also:
- GetFTime (92), FindFirst (86), FindNext (87), PackTime (96)
For an example, see PackTime (96).