MCPcopy Create free account
hub / github.com/NetHack/NetHack / _copyfile

Function _copyfile

outdated/sys/atari/tos.c:265–287  ·  view source on GitHub ↗
(from, to)

Source from the content-addressed store, hash-verified

263#define BIGBUF 8192
264
265int
266_copyfile(from, to)
267char *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
289int
290kbhit()

Callers

nothing calls this directly

Calls 5

openFunction · 0.85
closeFunction · 0.85
readFunction · 0.85
writeFunction · 0.85
allocFunction · 0.50

Tested by

no test coverage detected