home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / bcfamily / source / newsize.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-12  |  809 b   |  30 lines

  1. //
  2. //      *******************************************************************
  3. //        JdeBP C++ Library Routines          General Public Licence v1.00
  4. //            Copyright (c) 1991,1992     Jonathan de Boyne Pollard
  5. //      *******************************************************************
  6. //
  7. // Part of FamAPI.LIB
  8. //
  9.  
  10. #include "famapi.h"
  11. #include "dosdos.h"
  12.  
  13. //
  14. //    Change file size
  15. //
  16. USHORT _APICALL
  17. DosNewSize ( unsigned short fd, unsigned long size )
  18. {
  19.     long oldpos, endpos;
  20.     unsigned short err, nbytes;
  21.  
  22.     if (!(err = DosChgFilePtr(fd, 0L, 1, &oldpos))        // SEEK_CUR
  23.     &&  !(err = DosChgFilePtr(fd, size, 0, &endpos))    // SEEK_SET
  24.     &&  !(err = DosDosWrite(fd, NULL, 0, &nbytes))        // Internal version
  25.     &&  !(err = DosChgFilePtr(fd, oldpos, 0, &oldpos)))    // SEEK_SET
  26.         return NO_ERROR ;
  27.  
  28.     return err;
  29. }
  30.