home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol8n02.zip / USED.C < prev   
C/C++ Source or Header  |  1988-07-13  |  610b  |  31 lines

  1. /* used.c
  2.    calculates total bytes occupied by filespec passed on command line
  3.    If no parameter is passed, defaults to '*.*'
  4.  */
  5.  
  6. #include <dos.h>
  7. #include <stdio.h>
  8.  
  9. main(argc,argv)
  10. int argc;
  11. char *argv[];
  12. {
  13.     struct find_t SpaceUsedBy;
  14.     long total = 0L;
  15.  
  16.     if (argc < 2)
  17.     {
  18.         printf("\nUsage: used <filespec>\n");
  19.         exit(1);
  20.     }
  21.  
  22.     if(!_dos_findfirst(argv[1],_A_NORMAL,&SpaceUsedBy))
  23.         total = SpaceUsedBy.size;
  24.  
  25.     while(!_dos_findnext(&SpaceUsedBy))
  26.         total += SpaceUsedBy.size;
  27.  
  28.     printf("\n%s uses %ld bytes\n",argv[1],total);
  29. }
  30.  
  31.