]> mj.ucw.cz Git - libucw.git/commitdiff
Added "is_temp_file" attribute which causes automatic deletion of the
authorMartin Mares <mj@ucw.cz>
Sun, 4 Feb 2001 14:44:00 +0000 (14:44 +0000)
committerMartin Mares <mj@ucw.cz>
Sun, 4 Feb 2001 14:44:00 +0000 (14:44 +0000)
file upon bclose().

lib/fastbuf.h
lib/fb-file.c

index f1f0239ae8dac3177855a5919502d287e823353f..4e4461a6e1f4cb44a5f7f3de81841cce629126ef 100644 (file)
@@ -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 */
index fc8a19837f21da254fb0738ed564c6418169c9fb..ac25dcf3e954b1c663dcc5b288ba33625302abd4 100644 (file)
@@ -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 *