home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name qydisksp -- Return disk space allocation
- *
- * Synopsis freebytes = qydisksp(drive,paclus,ptclus,pbsec,psclus);
- *
- * long freebytes The number of bytes remaining in
- * unallocated sectors.
- * int drive The drive number (0 = default,
- * 1 = A:, etc.)
- * unsigned *paclus Available clusters
- * unsigned *ptclus Total number of clusters on the drive
- * unsigned *pbsec Bytes per sector
- * unsigned *psclus Sectors per cluster
- *
- * Description This function returns information on how the specified
- * disk is formatted, and on available space. The total
- * number of free bytes is returned as the functional
- * value.
- *
- * Space on disk is allocated in clusters; hence free space
- * is determined by the number of available clusters.
- * Depending on the medium (fixed or diskette), the cluster
- * size is determined when the disk is formatted.
- *
- * Note that since space is allocated by cluster, the
- * number of free bytes is not the total formatted space
- * minus the sum of the sizes of the files.
- *
- * Returns freebytes Total number of bytes remaining in
- * unallocated clusters. -1 is returned if
- * an invalid drive is specified.
- * *paclus Unallocated clusters remaining
- * *ptclus Total clusters on disk
- * *pbsec Bytes per sector
- * *psclus Sectors per cluster
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1983, 1984, 1986
- *
- * Version 3.02 March 20, 1987
- * Changed computation of returned value to avoid using
- * *paclus, *psclus, and *pbsec. This change allows the
- * pointers to point to the same location(s).
- *
- **/
-
- #include <bquery.h>
-
- long qydisksp(drive,paclus,ptclus,pbsec,psclus)
- int drive;
- unsigned *paclus,*ptclus,*pbsec,*psclus;
- {
- DOSREG dos_reg;
-
- dos_reg.ax = 0x3600; /* DOS function 0x36 */
- dos_reg.dx = drive;
- dos(&dos_reg);
- if (dos_reg.ax == 0xffff)
- return(-1L);
-
- *paclus = dos_reg.bx;
- *ptclus = dos_reg.dx;
- *pbsec = dos_reg.cx;
- *psclus = dos_reg.ax;
-
- return ( (long) dos_reg.bx
- * (long) dos_reg.ax
- * (long) dos_reg.cx);
- }