From f206399f88911e83d7e2b74579185cb01065aa18 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 4 Feb 2001 14:44:00 +0000 Subject: [PATCH] Added "is_temp_file" attribute which causes automatic deletion of the file upon bclose(). --- lib/fastbuf.h | 1 + lib/fb-file.c | 2 ++ 2 files changed, 3 insertions(+) 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 * -- 2.39.2