home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / QYDISKSP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-04-13  |  2.1 KB  |  70 lines

  1. /**
  2. *
  3. * Name        qydisksp -- Return disk space allocation
  4. *
  5. * Synopsis    freebytes = qydisksp(drive,paclus,ptclus,pbsec,psclus);
  6. *
  7. *        long freebytes      The number of bytes remaining in
  8. *                  unallocated sectors.
  9. *        int  drive      The drive number (0 = default,
  10. *                  1 = A:, etc.)
  11. *        unsigned *paclus  Available clusters
  12. *        unsigned *ptclus  Total number of clusters on the drive
  13. *        unsigned *pbsec   Bytes per sector
  14. *        unsigned *psclus  Sectors per cluster
  15. *
  16. * Description    This function returns information on how the specified
  17. *        disk is formatted, and on available space.  The total
  18. *        number of free bytes is returned as the functional
  19. *        value.
  20. *
  21. *        Space on disk is allocated in clusters; hence free space
  22. *        is determined by the number of available clusters.
  23. *        Depending on the medium (fixed or diskette), the cluster
  24. *        size is determined when the disk is formatted.
  25. *
  26. *        Note that since space is allocated by cluster, the
  27. *        number of free bytes is not the total formatted space
  28. *        minus the sum of the sizes of the files.
  29. *
  30. * Returns    freebytes      Total number of bytes remaining in
  31. *                  unallocated clusters. -1 is returned if
  32. *                  an invalid drive is specified.
  33. *        *paclus       Unallocated clusters remaining
  34. *        *ptclus       Total clusters on disk
  35. *        *pbsec          Bytes per sector
  36. *        *psclus       Sectors per cluster
  37. *
  38. * Version    3.0  (C)Copyright Blaise Computing Inc. 1983, 1984, 1986
  39. *
  40. * Version    3.02 March 20, 1987
  41. *        Changed computation of returned value to avoid using
  42. *          *paclus, *psclus, and *pbsec.  This change allows the
  43. *          pointers to point to the same location(s).
  44. *
  45. **/
  46.  
  47. #include <bquery.h>
  48.  
  49. long qydisksp(drive,paclus,ptclus,pbsec,psclus)
  50. int drive;
  51. unsigned *paclus,*ptclus,*pbsec,*psclus;
  52. {
  53.     DOSREG dos_reg;
  54.  
  55.     dos_reg.ax = 0x3600;          /* DOS function 0x36          */
  56.     dos_reg.dx = drive;
  57.     dos(&dos_reg);
  58.     if (dos_reg.ax == 0xffff)
  59.        return(-1L);
  60.  
  61.     *paclus = dos_reg.bx;
  62.     *ptclus = dos_reg.dx;
  63.     *pbsec  = dos_reg.cx;
  64.     *psclus = dos_reg.ax;
  65.  
  66.     return (  (long) dos_reg.bx
  67.         * (long) dos_reg.ax
  68.         * (long) dos_reg.cx);
  69. }
  70.