Sign in Join
FPDoc Onlineexperiment

DiskFree function

In unit Dos

Get free size on Disk.

Declaration

pascal
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 Unices: 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 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

Example: ex6

pascal
Program Example6;
uses Dos;

{ Program to demonstrate the DiskSize and DiskFree function. }

begin
  WriteLn('This partition size has ',DiskSize(0),' bytes');
  WriteLn('Currently ',DiskFree(0),' bytes are free');
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.