Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <direct.h>
    unsigned _getdiskfree( unsigned drive,
                            struct diskfree_t *diskspace );
    struct diskfree_t {
            unsigned short total_clusters;
            unsigned short avail_clusters;
            unsigned short sectors_per_cluster;
            unsigned short bytes_per_sector;
    };

Description:
    The _getdiskfree function uses system call 0x36 to obtain useful
    information on the disk drive specified by drive.  Specify 0 for the
    default drive, 1 for drive A, 2 for drive B, etc.  The information about
    the drive is returned in the structure  diskfree_t pointed to by
    diskspace.

Returns:
    The _getdiskfree function returns zero if successful.  Otherwise, it
    returns a non-zero value and sets  errno to  EINVAL indicating an
    invalid drive was specified.

Example:
    #include <stdio.h>
    #include <direct.h>

    void main()
      {
        struct diskfree_t disk_data;

        /* get information about drive 3 (the C drive) */
        if( _getdiskfree( 3, &disk_data ) == 0 ) {
          printf( "total clusters: %u\n",
                            disk_data.total_clusters );
          printf( "available clusters: %u\n",
                            disk_data.avail_clusters );
          printf( "sectors/cluster: %u\n",
                            disk_data.sectors_per_cluster );
          printf( "bytes per sector: %u\n",
                            disk_data.bytes_per_sector );
        } else {
          printf( "Invalid drive specified\n" );
        }
      }

    produces the following:

    total clusters: 16335
    available clusters: 510
    sectors/cluster: 4
    bytes per sector: 512

Classification:
    DOS

Systems:
    DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

See Also:
    _dos_getdiskfree, _dos_getdrive, _dos_setdrive, _getdrive

See Also: _dos_getdiskfree _dos_getdrive

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson