Header File
dos.h
Category
Directory Control Routines, Miscellaneous Routines
Prototype
void getdfree(unsigned char drive, struct dfree *dtable);
Description
Gets disk free space.
getdfree accepts a drive specifier in drive (0 for default, 1 for A, and so on) and fills the dfree structure pointed to by dtable 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 (unsigned) -1.
Example
#include <stdio.h> #include <dos.h> #include <process.h> int main(void) { struct dfree free; long avail; getdfree(0, &free); if ( free.df_sclus == -1) { printf("Error in getdfree() call\n"); exit(1); } avail = (long) free.df_avail * (long) free.df_bsec * (long) free.df_sclus; printf("The current drive has %ld bytes available\n", avail); return 0; }
Portability
POSIX |
Win32 |
ANSI C |
ANSI C++ |
|
+ |
|
|
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|