home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / RMTMP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.4 KB  |  56 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - rmtmp.c
  3.  *
  4.  * function(s)
  5.  *        rmtmp - close and delete open temporary file streams
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #include <stdio.h>
  18. #include <RtlData.h>
  19.  
  20. /*------------------------------------------------------------------------*
  21.  
  22. Name            rmtmp - close and delete open temporary streams
  23.  
  24. Usage           int rmtmp(void);
  25.  
  26. Prototype in    stdio.h
  27.  
  28. Description     rmtmp closes and deletes all open temporary file streams,
  29.                 which were previously created with tmpfil().  The current
  30.                 directory must the same as when the files were created, or
  31.                 the files will not be deleted.
  32.  
  33. Return value    rmtmp returns the total number of temporary files
  34.                 it closed and deleted.
  35.  
  36. *-------------------------------------------------------------------------*/
  37. int rmtmp( void )
  38.   {
  39.   FILE *fp;
  40.   int   i, cnt;
  41.   _QRTLDataBlock;
  42.  
  43.   for( i = 5, fp = _QRTLInstanceData(_streams) + 5, cnt = 0;
  44.        i < _QRTLInstanceData(_nfile);
  45.        fp++, i++
  46.      )
  47.     {
  48.     if( fp->istemp != 0 )
  49.       {
  50.       if( fclose( fp ) == 0 )  cnt++;
  51.       }
  52.     }
  53.  
  54.   return( cnt );
  55.   }
  56.