aboutsummaryrefslogtreecommitdiffstats
path: root/util/iobuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/iobuf.c')
-rw-r--r--util/iobuf.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/util/iobuf.c b/util/iobuf.c
index 6c4a5f5da..466f07e31 100644
--- a/util/iobuf.c
+++ b/util/iobuf.c
@@ -249,6 +249,7 @@ iobuf_alloc(int usage, size_t bufsize)
a->d.size = bufsize;
a->no = ++number;
a->subno = 0;
+ a->opaque = NULL;
return a;
}
@@ -280,7 +281,13 @@ iobuf_close( IOBUF a )
int
iobuf_cancel( IOBUF a )
{
- /* FIXME: do an unlink if usage is 2 */
+ const char *s;
+
+ if( a->usage == 2 ) {
+ s = iobuf_get_fname(a);
+ if( s && *s )
+ remove(s); /* remove the file. Fixme: this will fail for MSDOZE*/
+ } /* because the file is still open */
return iobuf_close(a);
}
@@ -404,6 +411,7 @@ iobuf_push_filter( IOBUF a,
b->recorder.buf = NULL;
/* make a link from the new stream to the original stream */
a->chain = b;
+ a->opaque = b->opaque;
/* setup the function on the new stream */
a->filter = f;
@@ -734,6 +742,23 @@ iobuf_get_filelength( IOBUF a )
}
/****************
+ * Retrieve the filename
+ */
+const char *
+iobuf_get_fname( IOBUF a )
+{
+ struct stat st;
+
+ for( ; a; a = a->chain )
+ if( !a->chain && a->filter == file_filter ) {
+ file_filter_ctx_t *b = a->filter_ov;
+ return b->fname;
+ }
+
+ return NULL;
+}
+
+/****************
* Start the block write mode, see rfc1991.new for details.
* A value of 0 for N stops this mode (flushes and writes
* the end marker)