9 extern char *mktemp(), *strcpy();
11 integer f_end(a) alist *a;
14 if(a->aunit>=MXUNIT || a->aunit<0) err(a->aerr,101,"endfile");
18 (void) sprintf(nbuf,"fort.%ld",a->aunit);
19 close(creat(nbuf, 0666));
23 return(b->useek ? t_runc(a) : 0);
35 if ((k = open(from, O_RDONLY)) < 0)
37 if ((tmp = creat(to,0666)) < 0)
39 while((n = read(k, buf, len > BUFSIZ ? BUFSIZ : (int)len)) > 0) {
40 if (write(tmp, buf, n) != n)
47 return n < 0 ? 1 : rc;
58 if(b->url) return(0); /*don't truncate direct files*/
60 (void) fseek(b->ufd,0L,SEEK_END);
62 if (loc >= len || b->useek == 0 || b->ufnm == NULL)
64 rewind(b->ufd); /* empty buffer */
66 if (close(creat(b->ufnm,0666)))
67 { rc = 1; goto done; }
72 (void) strcpy(nm,"tmp.FXXXXXX");
74 if (copy(b->ufnm, loc, nm)
75 || copy(nm, loc, b->ufnm))
79 fseek(b->ufd, loc, SEEK_SET);
81 err(a->aerr,111,"endfile");