From 6546f1a197d3cecafc7ddadcf96dd755c365edd0 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Lopes Date: Tue, 2 Oct 2007 16:47:19 +0000 Subject: [PATCH] Change burn_source implementation to fit libburn requirements. --- libisofs/ecma119.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index 2dad358..dcbc698 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -867,10 +867,19 @@ bs_read(struct burn_source *bs, unsigned char *buf, int size) { struct ecma119_write_target *t = (struct ecma119_write_target*)bs->data; - assert(size == t->block_size); + if (size != t->block_size) { + printf("[ERROR] You can only read in %d chunks\n", t->block_size); + return -1; + } if (t->curblock >= t->vol_space_size) { - return 0; + /* total_size could be setted by libburn */ + if ( t->curblock >= (t->total_size / (off_t) t->block_size) ) { + /* we pad the image */ + memset(buf, 0, size); + return size; + } + return -1; } if (t->state_data_valid) write_data_chunk(t, buf); @@ -908,8 +917,10 @@ bs_free_data(struct burn_source *bs) t->state_files.src->close(t->state_files.src); } -int bs_set_size(struct burn_source *source, off_t size) +int bs_set_size(struct burn_source *bs, off_t size) { + struct ecma119_write_target *t = (struct ecma119_write_target*)bs->data; + t->total_size = size; return 1; }