home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
OS2UTIL.ZIP
/
SIZE.C
< prev
next >
Wrap
Text File
|
1990-05-21
|
2KB
|
60 lines
#define INCL_SUB 1
#include "os2.h"
#include "stdio.h"
#include "math.h"
#include "ctype.h"
#include "string.h"
#include "stdlib.h"
#define HALF 171
#define QUARTER 172
int main(int argc, char* *argv);
main(argc, argv)
int argc;
char *argv[];
{
int flcnt = 0;
unsigned long filetot = 0L, diskftot = 0L, diskmtot = 0L, hardtot = 0L;
HDIR hdir = 0xFFFF;
USHORT usSearchCount = 1;
FILEFINDBUF findbuf;
char mask[80];
puts("SIZE Vers. 1.0 - Jan. 1990 - OS/2 Version\n");
if (argc > 2) {
puts("Invalid parameter(s)");
puts("or file(s) not found");
exit(1);
}
if (argc == 1)
strcpy(mask, "*.*");
else {
strcpy(mask, argv[1]);
if ('A'<=toupper(argv[1][0]) && toupper(argv[1][0])<='Z' && argv[1][1] == ':' &&
(strlen(argv[1]) == 2 || (strlen(argv[1]) == 3 && argv[1][2] == '\\')) )
strcat(mask, "*.*");
}
if (!DosFindFirst(mask, &hdir, 0x00, &findbuf,
sizeof(findbuf), &usSearchCount, 0L))
do {
++flcnt;
filetot += findbuf.cbFile;
diskmtot += 512L*(long)ceil((double)findbuf.cbFile/512.0);
diskftot += 1024L*(long)ceil((double)findbuf.cbFile/1024.0);
hardtot += 2048L*(long)ceil((double)findbuf.cbFile/2048.0);
}
while (!DosFindNext(hdir, &findbuf, sizeof(findbuf), &usSearchCount));
else {
puts("Invalid parameter(s)");
puts("or file(s) not found");
exit(1);
}
printf("%8lu bytes in %4d file%c\n", filetot, flcnt, (flcnt == 1) ? ' ' : 's');
printf("%8lu bytes required on 3%c\" diskette(s)\n", diskmtot, HALF);
printf("%8lu bytes required on 5%c\" diskette(s)\n", diskftot, QUARTER);
printf("%8lu bytes required on fixed disk\n", hardtot);
return(0);
}