Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | |||
8 | int truncate(const char *fn, off_t where) |
||
9 | { |
||
10 | int fd = open(fn, O_WRONLY); |
||
11 | if (fd < 0) |
||
12 | return -1; |
||
13 | if (lseek(fd, where, 0) < 0) |
||
14 | { |
||
15 | close(fd); |
||
16 | return -1; |
||
17 | } |
||
18 | if (_write(fd, 0, 0) < 0) |
||
19 | { |
||
20 | close(fd); |
||
21 | return -1; |
||
22 | } |
||
23 | return close(fd); |
||
24 | }>>> |