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/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <dos.h>
    unsigned _dos_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 _dos_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 _dos_getdiskfree function returns zero if successful.  Otherwise, it
    returns a non-zero value and sets  errno to  EINVAL indicating an
    invalid drive was specified.

See Also:
    _dos_getdrive, _dos_setdrive

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

    void main()
      {
        struct diskfree_t disk_data;

        /* get information about drive 3 (the C drive) */
        if( _dos_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, Win, NT, DOS/PM

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