| 263 | #define BIGBUF 8192 |
| 264 | |
| 265 | int |
| 266 | _copyfile(from, to) |
| 267 | char *from, *to; |
| 268 | { |
| 269 | int fromfd, tofd, r; |
| 270 | char *buf; |
| 271 | |
| 272 | fromfd = open(from, O_RDONLY | O_BINARY, 0); |
| 273 | if (fromfd < 0) |
| 274 | return -1; |
| 275 | tofd = open(to, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, FCMASK); |
| 276 | if (tofd < 0) { |
| 277 | close(fromfd); |
| 278 | return -1; |
| 279 | } |
| 280 | buf = (char *) alloc((unsigned) BIGBUF); |
| 281 | while ((r = read(fromfd, buf, BIGBUF)) > 0) |
| 282 | write(tofd, buf, r); |
| 283 | close(fromfd); |
| 284 | close(tofd); |
| 285 | free((genericptr_t) buf); |
| 286 | return 0; /* successful */ |
| 287 | } |
| 288 | |
| 289 | int |
| 290 | kbhit() |