home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / SPACE3.ZIP / SPACE.C < prev    next >
Text File  |  1990-11-27  |  2KB  |  60 lines

  1.  
  2. // THIS IS SPACE.C
  3.  
  4. #define INCL_DOS
  5. //#define INCL_DOSFILEMGR
  6. #include <os2def.h>
  7. #include <bse.h>
  8. #include <stdio.h>
  9.  
  10. static USHORT rc;
  11.  
  12. unsigned prtspace(unsigned drive) 
  13.     {
  14.     FSALLOCATE FSInfoBuf; /* File system info buffer */
  15.     ULONG clustersize; 
  16.     rc=DosQFSInfo(drive,(unsigned) 1,(PBYTE) &FSInfoBuf,sizeof(FSInfoBuf));
  17.     if ( rc )
  18.         {
  19.         printf("DosQFSInfo returned rc=%u\n",rc);
  20.         return rc;
  21.         }
  22.     clustersize=FSInfoBuf.cbSector*FSInfoBuf.cSectorUnit;
  23.     printf("On drive %c, there are %lu allocation units available,\n",
  24.                                (char) drive+'@',FSInfoBuf.cUnitAvail);
  25.     printf("Each allocation unit is %lu bytes, total space=%lu\n",
  26.                         clustersize,clustersize*FSInfoBuf.cUnitAvail);
  27.     return 0;
  28.     }
  29.  
  30. unsigned main(int argc, char *argv[])
  31.     {
  32.     int ix;
  33.     char temp;
  34.     USHORT DriveNumber;
  35.     ULONG  LogicalDriveMap;
  36.     rc=DosQCurDisk(&DriveNumber,&LogicalDriveMap);
  37.     if ( rc )
  38.         {
  39.         printf("DosQCurDisk returned rc=%u\n",rc);
  40.         return rc;
  41.         }
  42.     if ( argc<2 ) return prtspace(DriveNumber);
  43.     for ( ix=1 ; ix<argc ; ++ix )
  44.         {
  45.         temp=*argv[ix];
  46.         temp&='\xdf';
  47.         if ( 'A'>temp || 'Z'<temp )
  48.             {
  49.             printf("Parameter %d, \"%s\", is not a valid drive letter\n",
  50.                                                           ix,argv[ix]);
  51.             continue;
  52.             }
  53.         DriveNumber=temp-'@';
  54.         if ( 1L<<(DriveNumber-1) & LogicalDriveMap ) prtspace(DriveNumber);
  55.         else printf("Parameter %d, \"%s\", is not a valid drive letter\n",
  56.                                                            ix,argv[ix]);
  57.         }
  58.     return rc;
  59.     }
  60.