X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Ffb-file.c;h=73a2f14337a856f3034b3cca9e04276b7adec297;hb=3b0d474dd52fab80a5adca3b4b82c2db47a88657;hp=1fc85de5ed500445ec178a237961ce9bdd63a974;hpb=43ad0ca991bb413356651deac398aea6a92eb52d;p=libucw.git diff --git a/lib/fb-file.c b/lib/fb-file.c index 1fc85de5..73a2f143 100644 --- a/lib/fb-file.c +++ b/lib/fb-file.c @@ -63,9 +63,14 @@ bfd_seek(struct fastbuf *f, sh_off_t pos, int whence) static void bfd_close(struct fastbuf *f) { - close(FB_FILE(f)->fd); - if (FB_FILE(f)->is_temp_file && unlink(f->name) < 0) - die("unlink(%s): %m", f->name); + switch (FB_FILE(f)->is_temp_file) + { + case 1: + if (unlink(f->name) < 0) + log(L_ERROR, "unlink(%s): %m", f->name); + case 0: + close(FB_FILE(f)->fd); + } xfree(f); } @@ -113,6 +118,14 @@ bfdopen(int fd, uns buffer) return bfdopen_internal(fd, buffer, x); } +struct fastbuf * +bfdopen_shared(int fd, uns buffer) +{ + struct fastbuf *f = bfdopen(fd, buffer); + FB_FILE(f)->is_temp_file = -1; + return f; +} + void bbcopy(struct fastbuf *f, struct fastbuf *t, uns l) { uns rf = f->bstop - f->bptr;