X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Ffb-file.c;h=ac25dcf3e954b1c663dcc5b288ba33625302abd4;hb=bf1a6d75a8dbd2999321a3d6e1a7be91adb804ea;hp=5fca69dafbcb278cfeafad95d28df8c051a1633c;hpb=168c1f2ddcb8ce07248b4079b6398afe8c2d792a;p=libucw.git diff --git a/lib/fb-file.c b/lib/fb-file.c index 5fca69da..ac25dcf3 100644 --- a/lib/fb-file.c +++ b/lib/fb-file.c @@ -4,15 +4,15 @@ * (c) 1997--2000 Martin Mares */ +#include "lib/lib.h" +#include "lib/fastbuf.h" +#include "lib/lfs.h" + #include #include #include #include -#include "lib.h" -#include "fastbuf.h" -#include "lfs.h" - static int bfd_refill(struct fastbuf *f) { @@ -64,13 +64,15 @@ static void bfd_close(struct fastbuf *f) { close(f->fd); + if (f->is_temp_file && unlink(f->name) < 0) + die("unlink(%s): %m", f->name); } -struct fastbuf * +static struct fastbuf * bfdopen_internal(int fd, uns buflen, byte *name) { int namelen = strlen(name) + 1; - struct fastbuf *b = xmalloc(sizeof(struct fastbuf) + buflen + namelen); + struct fastbuf *b = xmalloc_zero(sizeof(struct fastbuf) + buflen + namelen); b->buflen = buflen; b->buffer = (char *)(b+1); @@ -78,7 +80,6 @@ bfdopen_internal(int fd, uns buflen, byte *name) b->bufend = b->buffer + buflen; b->name = b->bufend; strcpy(b->name, name); - b->pos = b->fdpos = 0; b->fd = fd; b->refill = bfd_refill; b->spout = bfd_spout;