home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snpd9707.zip / FUPDATE.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  2KB  |  68 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /************************************************************************/
  4. /*                                                                      */
  5. /*  FUPDATE.C                                                           */
  6. /*                                                                      */
  7. /*  Functions to flush  disk buffers to disk.                           */
  8. /*                                                                      */
  9. /*  Original Copyright 1990-93 by Robert B. Stout as part of            */
  10. /*  the MicroFirm Function Library (MFL)                                */
  11. /*                                                                      */
  12. /*  The user is granted a free limited license to use this source file  */
  13. /*  to create royalty-free programs, subject to the terms of the        */
  14. /*  license restrictions specified in the LICENSE.MFL file.             */
  15. /*                                                                      */
  16. /************************************************************************/
  17.  
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <dos.h>
  21. #include <io.h>
  22. #include "dosfiles.h"
  23.  
  24. /*
  25. **  fdupdate()
  26. **
  27. **  Update a file by handle reference.
  28. **
  29. **  Arguments: 1 - Handle of file to update
  30. **
  31. **  Returns: Success_ or error code
  32. */
  33.  
  34. int fdupdate(int fd)
  35. {
  36.       if (3 > _osmajor || (3 == _osmajor && 3 > _osminor))
  37.       {
  38.             return close(dup(fd));
  39.       }
  40.       else
  41.       {
  42.             union REGS regs;
  43.  
  44.             regs.h.ah = 0x68;
  45.             regs.x.bx = fd;
  46.             intdos(®s, ®s);
  47.             if (regs.x.cflag)
  48.                   return regs.x.ax;
  49.             else  return Success_;
  50.       }
  51. }
  52.  
  53. /*
  54. **  fupdate()
  55. **
  56. **  Update a C buffered file.
  57. **
  58. **  Arguments: 1 - FILE pointer of file to update
  59. **
  60. **  Returns: Success_ or error code
  61. */
  62.  
  63. int fupdate(FILE *fp)
  64. {
  65.       fflush(fp);
  66.       return fdupdate(fileno(fp));
  67. }
  68.