diff --git a/src/isofs_wrap.c b/src/isofs_wrap.c index 1a59cf04..7b670f93 100644 --- a/src/isofs_wrap.c +++ b/src/isofs_wrap.c @@ -76,6 +76,7 @@ int isoburn_read_volset(struct burn_drive *d, struct isoburn_read_opts *read_opt { int ret; struct ecma119_read_opts ropts; + enum burn_disc_status status; struct isoburn *o; assert(d && read_opts && volset); @@ -88,15 +89,34 @@ int isoburn_read_volset(struct burn_drive *d, struct isoburn_read_opts *read_opt return -1; } - // TODO replace with isoburn_disc_get_status() - // Check for suitable FULL or APPENDABLE status. Full only useful for image - // modification - if (o->fabricated_disc_status == BURN_DISC_BLANK) { - // FIXME construct an empty volset!! - *volset = NULL; + status = isoburn_disc_get_status(d); + if (status == BURN_DISC_BLANK) { + struct iso_volume *volume; + struct iso_tree_node_dir *root; + + /* + * Blank disc, we create a new volset without files. + */ + + root = iso_tree_new_root(); + if (!root) + return -1; + + volume = iso_volume_new_with_root("NEW DISC", "", "LIBISOBURN", root); + if (!volume) + return -1; + + *volset = iso_volset_new(volume, "NEW VOLSET"); + if (!*volset) + return -1; return 1; } - + + if (status != BURN_DISC_APPENDABLE && status != BURN_DISC_FULL) { + /* incorrect disc status */ + return -4; + } + ret = isoburn_disc_get_msc1(d, (int*) &ropts.block); if (ret < 0) return -2; diff --git a/src/libisoburn.h b/src/libisoburn.h index 9e2291f3..7e747b41 100644 --- a/src/libisoburn.h +++ b/src/libisoburn.h @@ -114,10 +114,8 @@ struct isoburn_read_opts { Not a wrapper, but peculiar to libisoburn. @param d The drive which holds an existing ISO filesystem @param read_opts The read options which can be chosen by the application - @param volset the volset that represents the image, or NULL if the image is - empty. - <<<<< What about return a volset without file if image is - empty <<<<<<<<< + @param volset the volset that represents the image, if the disc is blacnk + it will have no files @return <=0 error , 1 = success >>>>> error means damaged or unsupported image error code is stored in ecma119_read_opts in libisofs diff --git a/test/test.c b/test/test.c index 596a346d..e9cd4e60 100644 --- a/test/test.c +++ b/test/test.c @@ -117,17 +117,6 @@ int main(int argc, char **argv) printf("Can't read volset\n"); goto exit_cleanup; } - printf("Volset read\n"); - fflush(stdout); - - if (!volset) { - // TODO this piece of code should be inside libisoburn - struct iso_volume *volume; - - root = iso_tree_new_root(); - volume = iso_volume_new_with_root("NEW DISC", "", "LIBISOBURN", root); - volset = iso_volset_new( volume, "VOLSETID" ); - } root = iso_volume_get_root(iso_volset_get_volume(volset, 0)); /* add a new dir */