| 1 | #include <unistd.h> |
| 2 | #include <fcntl.h> |
| 3 | #include <errno.h> |
| 4 | |
| 5 | int truncate64(const char *pathname, _off64_t len){ |
| 6 | int ret, err; |
| 7 | int fd = _open(pathname,_O_BINARY|_O_RDWR); |
| 8 | if (fd == -1) return fd; |
| 9 | ret = ftruncate64(fd,len); |
| 10 | err = errno; |
| 11 | _close(fd); |
| 12 | errno = err; |
| 13 | return ret; |
| 14 | } |