Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
DISK.PAS
◄Example► ◄Contents► ◄Index► ◄Back►
PROGRAM disk;
{ DISK.PAS illustrates low-level disk access using the following
functions:
DiskFree DiskSize GetDir
}
USES
Dos;
CONST
program_name = 'DISK ';
program_desc = 'displays disk size and number of free bytes.';
program_synt = 'Syntax: DISK <letter> (default is current drive)';
VAR
disk_drive : Word;
current_dir : STRING;
drive_letter : STRING;
total_size : LongInt;
BEGIN
Writeln( program_name, program_desc );
Writeln( program_synt );
Writeln;
IF ParamCount = 0 THEN
BEGIN
disk_drive := 0;
GetDir( disk_drive, current_dir );
drive_letter := Copy( current_dir, 1, 1 );
END
ELSE BEGIN
drive_letter := Copy( ParamStr( 1 ), 1, 1 );
drive_letter[1] := UpCase( drive_letter[1] );
disk_drive := Ord( drive_letter[1] ) - 64;
END;
total_size := DiskSize( disk_drive );
IF (total_size = -1) THEN
Writeln( drive_letter, ': Invalid drive.' )
ELSE BEGIN
Writeln( 'Total size of disk ', drive_letter, ': is ',
total_size, '.' );
Writeln( DiskFree( disk_drive ), ' bytes are free.' );
END;
END.