uns favail, tavail, n;
favail = bdirect_read_prepare(f, &fptr);
- if (favail == (uns)EOF)
+ if (!favail)
die("bbcopy: source exhausted");
tavail = bdirect_write_prepare(t, &tptr);
n = MIN(l, favail);
int (*config)(struct fastbuf *, uns, int); /* Configure the stream */
};
-/* FastIO on standard files */
+/* FastIO on standard files (specify buffer size 0 to enable mmaping) */
struct fastbuf *bopen(byte *name, uns mode, uns buffer);
struct fastbuf *bopen_tmp(uns buffer);
/* Direct I/O on buffers */
-static inline int
+static inline uns
bdirect_read_prepare(struct fastbuf *f, byte **buf)
{
if (f->bptr == f->bstop && !f->refill(f))
- return EOF;
+ return 0;
*buf = f->bptr;
return f->bstop - f->bptr;
}
f->bptr = pos;
}
-static inline int
+static inline uns
bdirect_write_prepare(struct fastbuf *f, byte **buf)
{
if (f->bptr == f->bufend)