]> mj.ucw.cz Git - libucw.git/commitdiff
Introduced bfilesize().
authorMartin Mares <mj@ucw.cz>
Tue, 6 Jul 2004 11:18:27 +0000 (11:18 +0000)
committerMartin Mares <mj@ucw.cz>
Tue, 6 Jul 2004 11:18:27 +0000 (11:18 +0000)
lib/fastbuf.c
lib/fastbuf.h

index d2e08f8648def7918c8fc04404f530aa18fabd0b..85df8250370f10197234d902f4cbcc908fd73895 100644 (file)
@@ -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;
+}
index 45ce06916f0c388831a57d3293104a810a684c61..65245b6266720c8a2fab0f7fcbc38bf33bf91509 100644 (file)
@@ -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)
 {