home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
SPACE3.ZIP
/
SPACE.C
< prev
next >
Wrap
Text File
|
1990-11-27
|
2KB
|
60 lines
// THIS IS SPACE.C
#define INCL_DOS
//#define INCL_DOSFILEMGR
#include <os2def.h>
#include <bse.h>
#include <stdio.h>
static USHORT rc;
unsigned prtspace(unsigned drive)
{
FSALLOCATE FSInfoBuf; /* File system info buffer */
ULONG clustersize;
rc=DosQFSInfo(drive,(unsigned) 1,(PBYTE) &FSInfoBuf,sizeof(FSInfoBuf));
if ( rc )
{
printf("DosQFSInfo returned rc=%u\n",rc);
return rc;
}
clustersize=FSInfoBuf.cbSector*FSInfoBuf.cSectorUnit;
printf("On drive %c, there are %lu allocation units available,\n",
(char) drive+'@',FSInfoBuf.cUnitAvail);
printf("Each allocation unit is %lu bytes, total space=%lu\n",
clustersize,clustersize*FSInfoBuf.cUnitAvail);
return 0;
}
unsigned main(int argc, char *argv[])
{
int ix;
char temp;
USHORT DriveNumber;
ULONG LogicalDriveMap;
rc=DosQCurDisk(&DriveNumber,&LogicalDriveMap);
if ( rc )
{
printf("DosQCurDisk returned rc=%u\n",rc);
return rc;
}
if ( argc<2 ) return prtspace(DriveNumber);
for ( ix=1 ; ix<argc ; ++ix )
{
temp=*argv[ix];
temp&='\xdf';
if ( 'A'>temp || 'Z'<temp )
{
printf("Parameter %d, \"%s\", is not a valid drive letter\n",
ix,argv[ix]);
continue;
}
DriveNumber=temp-'@';
if ( 1L<<(DriveNumber-1) & LogicalDriveMap ) prtspace(DriveNumber);
else printf("Parameter %d, \"%s\", is not a valid drive letter\n",
ix,argv[ix]);
}
return rc;
}