Change burn_source implementation to fit libburn requirements.

This commit is contained in:
Vreixo Formoso Lopes 2007-10-02 16:47:19 +00:00
parent ba9e1127dd
commit 24ffd32605

View File

@ -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;
}