
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_dos_getdiskfree() get amount of free space on disk</b>
[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_dos_getdiskfree() Get amount of free space on disk
#include <dos.h>
unsigned _dos_getdiskfree(drive, diskspace);
unsigned drive; 0 = default drive, 1 = drive A, 2 = B, etc.
struct diskfree_t *diskspace; Location of returned disk information
_dos_getdiskfree() uses MS-DOS function 36h to obtain information
about the disk drive specified by 'drive'. The disk information is
returned in struct diskfree_t, defined in dos.h:
struct diskfree_t {
unsigned total_clusters;
unsigned avail_clusters;
unsigned sectors_per_cluster;
unsigned bytes_per_sector;
}
Returns: _dos_getdiskfree() returns 0 if successful, otherwise it
returns a nonzero value and sets errno to EINVAL to
indicate that an invalid drive was specified.
Portability: MS-DOS only, version 2.0 or higher
------------------------------- Example ---------------------------------
This program gets and prints the amount of free disk space, in bytes, on
drive C:
#include <dos.h>
main()
{
struct diskfree_t diskspace;
if (_dos_getdiskfree( 3, &diskspace) == 0)
{
printf("There are %lu bytes available on drive C:\n",
(unsigned long) diskspace.avail_clusters *
diskspace.sectors_per_cluster *
diskspace.bytes_per_sector);
}
else
printf("Invalid drive specified\n");
}
See Also: _dos_getdrive() _dos_setdrive()
Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson