From: Martin Mares Date: Sun, 4 Feb 2001 14:44:00 +0000 (+0000) Subject: Added "is_temp_file" attribute which causes automatic deletion of the X-Git-Tag: holmes-import~1564 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=f206399f88911e83d7e2b74579185cb01065aa18;p=libucw.git Added "is_temp_file" attribute which causes automatic deletion of the file upon bclose(). --- diff --git a/lib/fastbuf.h b/lib/fastbuf.h index f1f0239a..4e4461a6 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -43,6 +43,7 @@ struct fastbuf { sh_off_t pos; /* Position of buffer start in the file */ sh_off_t fdpos; /* Current position in the non-buffered file */ int fd; /* File descriptor, -1 if not a real file */ + int is_temp_file; /* Is a temporary file, delete on close */ void *lldata; /* Data private to access functions below */ void *llpos; /* ... continued ... */ int (*refill)(struct fastbuf *); /* Get a buffer with new data */ diff --git a/lib/fb-file.c b/lib/fb-file.c index fc8a1983..ac25dcf3 100644 --- a/lib/fb-file.c +++ b/lib/fb-file.c @@ -64,6 +64,8 @@ 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); } static struct fastbuf *