]> mj.ucw.cz Git - libucw.git/commitdiff
Allow SEEK_END. (I plan to rewrite seek in fbmem streams, the current
authorMartin Mares <mj@ucw.cz>
Fri, 23 Aug 2002 08:26:26 +0000 (08:26 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 23 Aug 2002 08:26:26 +0000 (08:26 +0000)
version is awfully slow.)

lib/fb-mem.c

index 07e4efbcf640e1465414334b30867b4bfe60ffad..41d0a6918d2f5a8ffe21e3b74d0fe473ac0cd612 100644 (file)
@@ -90,6 +90,17 @@ fbmem_seek(struct fastbuf *f, sh_off_t pos, int whence)
   struct msblock *b;
   unsigned int p = 0;
 
   struct msblock *b;
   unsigned int p = 0;
 
+  /* FIXME: Milan's quick hack to allow SEEK_END */
+  if (whence == SEEK_END)
+  {
+         for (b=m->first; b; b=b->next)
+                 p += b->size;
+         pos += p;
+         p=0;
+         whence = SEEK_SET;
+  }
+  /* EOQH */
+  
   if (whence != SEEK_SET)
     die("fbmem_seek: only SEEK_SET supported");
   for (b=m->first; b; b=b->next)
   if (whence != SEEK_SET)
     die("fbmem_seek: only SEEK_SET supported");
   for (b=m->first; b; b=b->next)