getdfree
raw OCR
Gets disk free space.
Defined in header <dos.h>
Syntax
#include <dos.h>
void getdfree(unsigned char drive, struct dfree *dtable);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
getdfree accepts a drive specifier in drive (0 for default, 1 for A, and so on) and fills the dfree structure pointed to by dtahle with disk attributes.
The dfree structure is defined as follows:
struct dfree {
| unsigned df_avail; | /* available clusters * |
| unsigned df_total; | /* total clusters */ |
| unsigned df_bsec; | /* bytes per sector */ |
| unsigned df_sclus; }; | /* sectors per cluster |
Return value
getdfree returns no value. In the event of an error, df_sclus in the dfree structure is set to 0xFFFF.
See also
Example
Unclude <stdio.h>
#include <stdlib.h>
#include <dir.h>
#include <dos.h>
int main (void)
{
struct dfree free;
long avail;
int drive;
drive = getdiskO ;
getdfree (drive+1, &free);
if (free.df_sclus == 0xFFFF) {
printf ("Error in getdfree() call\n");
exit(l);
}
avail = (long) free.df_avail * (long) free.df_bsec * (long) free.df_sclus;
printf ("Drive %c: has %ld bytes available\n", 'A' + drive, avail);
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/dos.h/getdfree/
· short form /3.1/getdfree/