home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / mag&info / msjv7_4.zip / OPEN.ARJ / CLOSTEMP.C next >
Text File  |  1992-07-01  |  1KB  |  42 lines

  1. /*
  2.       Copyright 1991 by David Thielen, All Rights Reserved.
  3.  
  4.       This code example is from a commercial product and has restricted
  5.       rights.  This code, or any code derived from this code may be
  6.       incorporated into any programs with the following restrictions;
  7.       1) It cannot be sold as source code, and 2) It cannot be sold in a
  8.       product which provides this code as an API.
  9. */
  10.  
  11.  
  12. #include "file_io.h"
  13.  
  14.  
  15. // First we truncate the file to 0 length.  If the delete fails (we
  16. // have the wrong name), at least we won't be taking up tons of disk
  17. // space.
  18.  
  19. // ALSO - DOS will not need to write any dirty buffers if we truncate
  20. // the file first.  If we close first, it will write the dirty buffers
  21. // and then close.
  22.  
  23. // Once the file is closed, we need to delete it.
  24.  
  25. unsigned FileCloseTemp (int hFil,BYTE const *pFile)
  26. {
  27.    unsigned uRtn, uTmp;
  28.  
  29.  
  30.    // set to 0 length
  31.    FileSetSize (hFil, 0L);
  32.  
  33.    // Close it
  34.    uRtn = FileClose (hFil);
  35.  
  36.    // Delete it
  37.    if ((uTmp = FileDelete (pFile)) != 0)
  38.       return (uTmp);
  39.  
  40.    return (uRtn);
  41. }
  42.