home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / SYS / FTRUNCAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  583 b   |  29 lines

  1. /* sys/ftruncat.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <os2emx.h>
  5. #include "syscalls.h"
  6.  
  7. int __ftruncate (int handle, long length)
  8. {
  9.   ULONG rc;
  10.   FILESTATUS3 info;
  11.  
  12.   rc = DosQueryFileInfo (handle, FIL_STANDARD, &info, sizeof (info));
  13.   if (rc != 0)
  14.     {
  15.       _sys_set_errno (rc);
  16.       return (-1);
  17.     }
  18.   if (info.cbFile > length)
  19.     {
  20.       rc = DosSetFileSize (handle, length);
  21.       if (rc != 0)
  22.         {
  23.           _sys_set_errno (rc);
  24.           return (-1);
  25.         }
  26.     }
  27.   return (0);
  28. }
  29.