From be2907b0805c4d55f89657f07afda7e28bcbda02 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 6 Jul 2004 11:18:27 +0000 Subject: [PATCH] Introduced bfilesize(). --- lib/fastbuf.c | 12 ++++++++++++ lib/fastbuf.h | 1 + 2 files changed, 13 insertions(+) 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) { -- 2.39.2