From: Martin Mares Date: Tue, 6 Jul 2004 11:18:27 +0000 (+0000) Subject: Introduced bfilesize(). X-Git-Tag: holmes-import~962 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=be2907b0805c4d55f89657f07afda7e28bcbda02;p=libucw.git Introduced bfilesize(). --- diff --git a/lib/fastbuf.c b/lib/fastbuf.c index d2e08f86..85df8250 100644 --- a/lib/fastbuf.c +++ b/lib/fastbuf.c @@ -355,3 +355,15 @@ bskip(struct fastbuf *f, uns len) len -= l; } } + +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; +} diff --git a/lib/fastbuf.h b/lib/fastbuf.h index 45ce0691..65245b62 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -122,6 +122,7 @@ void bseek(struct fastbuf *f, sh_off_t pos, int whence); void bsetpos(struct fastbuf *f, sh_off_t pos); void brewind(struct fastbuf *f); void bskip(struct fastbuf *f, uns len); +sh_off_t bfilesize(struct fastbuf *f); static inline sh_off_t btell(struct fastbuf *f) {