Go to the first, previous, next, last section, table of contents.


_dos_getdiskfree

Syntax

#include <dos.h>

unsigned int _dos_getdiskfree(unsigned int drive, struct diskfree_t *diskspace);

Description

This function determines the free space on drive drive (0=default, 1=A:, 2=B:, etc.) and fills diskspace structure.

Return Value

Returns with 0 if successful and non-zero on error (sets errno=EINVAL).

Portability

not ANSI, not POSIX

Example

struct diskfree_t df;
unsigned long freebytes;

if ( !_dos_getdiskfree(0, &df) )
{
  freebytes = (unsigned long)df.avail_clusters *
              (unsigned long)df.bytes_per_sector *
              (unsigned long)df.sectors_per_cluster;
  printf("There is %lu free bytes on the current drive.\n", freebytes);
}
else
  printf("Unable to get free disk space.\n");


Go to the first, previous, next, last section, table of contents.