uint fileload(File *f, uint p0, int fd, int *nulls) { if(f->seq > 0) error("undo in file.load unimplemented"); return bufload(&f->b, p0, fd, nulls); }
uint fileload(File *f, uint p0, int fd, int *nulls) { if(f->seq > 0) panic("undo in file.load unimplemented"); return bufload(&f->Buffer, p0, fd, nulls); }
void getsnarf() { int nulls; if(snarfbuf.nc > MAXSNARF) return; if(snarffd < 0) return; seek(snarffd, 0, 0); bufreset(&snarfbuf); bufload(&snarfbuf, 0, snarffd, &nulls); }
Posn readio(File *f, int *nulls, int setdate, int toterm) { int n, b, w; Rune *r; Posn nt; Posn p = addr.r.p2; uint32_t dev; uint64_t qid; int32_t mtime; char buf[BLOCKSIZE+1], *s; *nulls = FALSE; b = 0; if(f->unread){ nt = bufload(f, 0, io, nulls); if(toterm) raspload(f); }else for(nt = 0; (n = read(io, buf+b, BLOCKSIZE-b))>0; nt+=(r-genbuf)){ n += b; b = 0; r = genbuf; s = buf; while(n > 0){ if((*r = *(uint8_t*)s) < Runeself){ if(*r) r++; else *nulls = TRUE; --n; s++; continue; } if(fullrune(s, n)){ w = chartorune(r, s); if(*r) r++; else *nulls = TRUE; n -= w; s += w; continue; } b = n; memmove(buf, s, b); break; } loginsert(f, p, genbuf, r-genbuf); } if(b) *nulls = TRUE; if(*nulls) warn(Wnulls); if(setdate){ if(statfd(io, &dev, &qid, &mtime, 0, 0) > 0){ f->dev = dev; f->qidpath = qid; f->mtime = mtime; checkqid(f); } } return nt; }