X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Ffastbuf.c;h=6fbb2184ca2d0a90a0135ab012e248db3e09fec1;hb=adccd410be409235bcd59425615101a06693f36d;hp=bf887a18f86acd33ae61603a62486b5a2fbf34b5;hpb=dfbf964395a2d01f4089138b4d9ecdd204a7e8c7;p=libucw.git diff --git a/lib/fastbuf.c b/lib/fastbuf.c index bf887a18..6fbb2184 100644 --- a/lib/fastbuf.c +++ b/lib/fastbuf.c @@ -1,5 +1,5 @@ /* - * Sherlock Library -- Fast Buffered I/O + * UCW Library -- Fast Buffered I/O * * (c) 1997--2004 Martin Mares * @@ -342,3 +342,31 @@ brewind(struct fastbuf *f) bflush(f); bsetpos(f, 0); } + +int +bskip_slow(struct fastbuf *f, uns len) +{ + while (len) + { + byte *buf; + uns l = bdirect_read_prepare(f, &buf); + if (!l) + return 0; + l = MIN(l, len); + bdirect_read_commit(f, buf+l); + len -= l; + } + return 1; +} + +sh_off_t +bfilesize(struct fastbuf *f) +{ + if (!f) + return 0; + sh_off_t pos = btell(f); + bseek(f, 0, SEEK_END); + sh_off_t len = btell(f); + bsetpos(f, pos); + return len; +}