correct handling of disc status and blank discs in read volset

This commit is contained in:
Vreixo Formoso Lopes 2007-09-23 16:23:55 +00:00
parent db6fc81ea8
commit b765efef60
3 changed files with 29 additions and 22 deletions

View File

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

View File

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

View File

@ -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 */