home *** CD-ROM | disk | FTP | other *** search
/ RBBS in a Box Volume 1 #2 / RBBS_vol1_no2.iso / add2 / jmd4tlx.zip / JSIZE.C < prev    next >
Text File  |  1989-03-20  |  2KB  |  53 lines

  1. /******************************************************************
  2. ** JSIZE.C
  3. **
  4. ** Syntax:  JSIZE <filename>
  5. **
  6. ** Returns: Writes a temporary file named "JSIZE.$$$" containing the
  7. **          integer size in bytes of the passed filename.
  8. **
  9. ** Notes:   This kludge is necessary because TELIX does not allow you to
  10. **          determine the size of a file by using the filesize() function
  11. **          if you are between calls to filefind() without destroying the
  12. **          buffer used in subsequent calls.  I wanted to do just that in
  13. **          order to be able to log performance characteristics for each
  14. **          JMODEM transfer.  Since I also allow the user to pass wildcards
  15. **          and multiple filenames, here it is.  See the JLOG.SLT source
  16. **          file for details regarding its use.  This file was compiled
  17. **          using Microsoft C 5.10.
  18. **
  19. ** Limits:  This will only work if the filesize is <= 9,999,999 bytes.
  20. **          This should not present a problem.  If it does, you may have
  21. **          take out a loan just to pay your phone bill!
  22. **
  23. ** Author:  Michael K. Bozovich
  24. **
  25. ** Date:    3-20-89
  26. **
  27. ********************************************************************/
  28.  
  29. #include <io.h>
  30. #include <stdio.h>
  31.  
  32. FILE *stream;
  33. unsigned long bytes;
  34.  
  35. main(argc, argv)
  36.  
  37. int argc;
  38. char *argv[];
  39.  
  40. {
  41.   stream = fopen(argv[1], "r");            /* Open the file for reading  */
  42.   bytes = filelength(fileno(stream));      /* Determine its size         */
  43.   fclose(stream);                          /* Close it                   */
  44.  
  45.   stream = fopen("jsize.$$$", "w+");       /* Open temporary file - it   */
  46.                                            /* is destroyed if it already */
  47.                                            /* exists!                    */
  48.   fprintf(stream, "%7lu", bytes);          /* Write the file size info   */
  49.   fclose(stream);                          /* Close it and return        */
  50. }
  51.  
  52. /* eof jsize.c */
  53.