1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7#include <errno.h>
8#include <io.h>
9#include <unistd.h>
10
11int __cdecl ftruncate64(int fd, _off64_t length)
12{
13 errno_t error;
14
15 /* _chsize_s calls invalid parameter exception handler, so validate input parameters */
16 if (fd < 0) {
17 errno = EBADF;
18 return -1;
19 }
20 if (length < 0) {
21 errno = EINVAL;
22 return -1;
23 }
24 error = _chsize_s(fd, length);
25 if (error) {
26 errno = error;
27 return -1;
28 }
29 return 0;
30}