File: ftruncate.c

package info (click to toggle)
pspp 0.7.9%2Bgit20120620-1.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 71,980 kB
  • sloc: ansic: 384,310; sh: 22,024; cpp: 1,445; yacc: 1,251; perl: 903; lisp: 868; makefile: 358; xml: 182; java: 5
file content (43 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* ftruncate emulations for native Windows.
   This file is in the public domain.  */

#include <config.h>

/* Specification.  */
#include <unistd.h>

#if HAVE_CHSIZE

# include <errno.h>
# include <io.h>

# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
#  include "msvc-inval.h"
static inline int
chsize_nothrow (int fd, long length)
{
  int result;

  TRY_MSVC_INVAL
    {
      result = chsize (fd, length);
    }
  CATCH_MSVC_INVAL
    {
      result = -1;
      errno = EBADF;
    }
  DONE_MSVC_INVAL;

  return result;
}
#  define chsize chsize_nothrow
# endif

int
ftruncate (int fd, off_t length)
{
  return chsize (fd, length);
}

#endif