_dos_getdiskfree
Gets disk free space.
Defined in header <dos.h>
Syntax
#include <dos.h>
unsigned _dos_getdiskfree(unsigned char drive, struct diskfree_t *dtable);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
_dos_getdlskfree accepts a drive specifier in drive (0 for default, 1 for A, 2 for B, and so on) and fills in the diskfree_t structure pointed to by dtable with disk characteristics.
The diskfree_t structure is defined as follows:
struct diskfree_t { unsigned avail_clusters; /* available clusters */ unsigned total_clusters; /* total clusters */ unsigned bytes_per_sector; /* bytes per sector */ unsigned sectors_per_cluster;/* sectors per cluster */ };
Return value
_dos_getdiskfree returns 0 if successful. Otherwise, it returns a non-zero value and and the global variable errno is set to EINVAL Invalid drive specified
See also
Example
#include <stdio.h>
#include <dos.h>
#include <process.h>
int main (void)
{
struct disk;free_t free;
long avail;
if (_dos_getdiskfree(0, &free) != 0) {
printf ("Error in _dos_getdiskfree() call\n");
exit(l);
}
avail = (long) free.avail_clusters
* (long) free.bytes_per_sector
* (long) free.sectors_per_cluster;
printf ("The current drive has %ld bytes available\n", 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/_dos_getdiskfree/
· short form /3.1/_dos_getdiskfree/