home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / OS2SP.ZIP / OS2SP.C < prev    next >
C/C++ Source or Header  |  1990-08-19  |  2KB  |  74 lines

  1.  
  2.  
  3. /************************************************************/
  4. /* OS2SP.C                                                  */
  5. /* Display Disk Space Information. (OS/2)                   */
  6. /* Mark J. Lussier.                                         */
  7. /* August 19, 1990.                                         */
  8. /*                                                          */
  9. /************************************************************/
  10.  
  11.  
  12. #define INCL_DOS
  13.  
  14. #include <stdio.h>
  15. #include <os2.h>
  16. #include <stdlib.h>
  17. #include <ctype.h>
  18.  
  19. main ( INT argc, CHAR *argv[] )
  20. {
  21.  
  22.   FSALLOCATE FSInfoBuf;
  23.   SHORT rc;
  24.   ULONG FreeSpace, TotalSpace,UsedSpace;
  25.   USHORT DriveSpec;
  26.  
  27.   printf("\n OS/2 Disk Space Checker.  By Mark (c) 1990 \n\n");
  28.  
  29.   DriveSpec = 0;
  30.   if ( argc > 1 )
  31.     DriveSpec = toupper(argv[1][0]) - 64;
  32.  
  33.  
  34.   if ( DriveSpec > 26 || DriveSpec < 0 )
  35.   {
  36.     printf("\n Invalid Drive Specification ! (Drive Letter Must be between A and Z)\n ");
  37.     exit ( 1 );
  38.   }
  39.  
  40.   rc = DosQFSInfo ( DriveSpec,
  41.                     1,
  42.                     (PBYTE) &FSInfoBuf,
  43.                     sizeof(FSInfoBuf) );
  44.  
  45.   if ( rc != 0 )
  46.     printf("\nInvalid Drive Specification!\n");
  47.   else
  48.   {
  49.     if ( FSInfoBuf.ulReserved == 0 )
  50.       printf("Standard DOS FAT File System \n\n");
  51.     else
  52.       printf("OS/2 High Performance File System. (HPFS)\n\n");
  53.  
  54.     TotalSpace = FSInfoBuf.cSectorUnit *
  55.                  FSInfoBuf.cUnit *
  56.                  FSInfoBuf.cbSector;
  57.     FreeSpace =  FSInfoBuf.cSectorUnit *
  58.                  FSInfoBuf.cUnitAvail *
  59.                  FSInfoBuf.cbSector ;
  60.  
  61.     UsedSpace = TotalSpace - FreeSpace;
  62.  
  63.     printf("Total Disk Space : %10lu Bytes, %8lu Kb, %8.1lf Megabytes\n",TotalSpace,TotalSpace/1024,(float)(TotalSpace)/1024.0/1024.0);
  64.     printf("Disk Space Used  : %10lu Bytes, %8lu Kb, %8.1lf Megabytes\n",UsedSpace,UsedSpace/1024,(float)(UsedSpace)/1024.0/1024.0);
  65.     printf("Free Disk Space  : %10lu Bytes, %8lu Kb, %8.1lf Megabytes\n",FreeSpace,FreeSpace/1024,(float)(FreeSpace)/1024.0/1024.0);
  66.  
  67.     printf("\n The Disk is %6.2f%% Free\n",(float)((float)(FreeSpace)/(float)(TotalSpace) * 100));
  68.  
  69.  
  70.  
  71.   }
  72.   exit ( 0 );
  73. }
  74.