New -blank and -format modes as_needed
This commit is contained in:
@ -558,8 +558,25 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
if(flag&1)
|
||||
if(xorriso->image_start_mode&(1<<31)) /* used up setting */
|
||||
xorriso->image_start_mode= 0; /* no need to perform auto setting */
|
||||
}
|
||||
drive= dinfo[0].drive;
|
||||
if(flag&1) {
|
||||
if(xorriso->image_start_mode&(1<<31)) /* used up setting */
|
||||
xorriso->image_start_mode&= ~0xffff; /* perform auto setting */
|
||||
if((xorriso->image_start_mode&(1<<30))) { /* if enabled at all */
|
||||
ret= isoburn_set_msc1(drive, xorriso->image_start_mode & 0xffff,
|
||||
xorriso->image_start_value, 0);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
if(xorriso->image_start_mode&(1<<31))
|
||||
xorriso->image_start_mode= 0; /* disable msc1 setting completely */
|
||||
else
|
||||
xorriso->image_start_mode|= (1<<31); /* mark as used up */
|
||||
}
|
||||
}
|
||||
state= isoburn_disc_get_status(drive);
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
if(flag&1) {
|
||||
@ -2337,7 +2354,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
|
||||
#ifdef Xorriso_new_toc_formaT
|
||||
|
||||
sprintf(respt, "TOC layout : %3s , %9s , %10s , %s\n",
|
||||
"Idx", "sbsector=", "Size", "Volume Id");
|
||||
"Idx", "sbsector", "Size", "Volume Id");
|
||||
if(!(flag&1))
|
||||
Xorriso_result(xorriso,0);
|
||||
#endif
|
||||
@ -2453,13 +2470,13 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
|
||||
ret= 0;
|
||||
else
|
||||
ret= isoburn_read_iso_head(drive, lba, &image_blocks, volume_id, 1);
|
||||
if(ret>0 && track_no==num_tracks-1) {
|
||||
if(ret>0 && track_no==0) {
|
||||
sprintf(respt, "ISO session : %3d , %9d , %9ds , %s\n",
|
||||
session_no+1, lba, image_blocks , volume_id);
|
||||
} else if(ret>0 && track_no==num_tracks-1) {
|
||||
} else if(ret>0) {
|
||||
sprintf(respt, "ISO track : %3d , %9d , %9ds , %s\n",
|
||||
track_count, lba, image_blocks , volume_id);
|
||||
} else if(track_no==num_tracks-1) {
|
||||
} else if(track_no==0) {
|
||||
sprintf(respt, "Other session: %3d , %9d , %9ds , \n",
|
||||
session_no+1, lba, track_size);
|
||||
} else {
|
||||
@ -2659,8 +2676,6 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
|
||||
|
||||
burn_disc_get_profile(drive, ¤t_profile, current_profile_name);
|
||||
|
||||
/* >>> */;
|
||||
|
||||
disc_state = isoburn_disc_get_status(drive);
|
||||
if(current_profile == 0x13) { /* overwriteable DVD-RW */
|
||||
/* Depending on flag bit1 formatted DVD-RW will get blanked to sequential
|
||||
@ -2714,6 +2729,7 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
|
||||
isoburn_disc_erase(drive, (flag&1));
|
||||
usleep(1000000);
|
||||
while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) {
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */
|
||||
percent = 1.0 + ((double) p.sector+1.0) / ((double) p.sectors) * 98.0;
|
||||
sprintf(xorriso->info_text, "Blanking ( %.1f%% done )", percent);
|
||||
@ -2726,7 +2742,9 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* @return 0=failure, did not touch media , -1=failure, altered media
|
||||
|
||||
/* @param flag bit0= try to achieve faster formatting
|
||||
@return 0=failure, did not touch media , -1=failure, altered media
|
||||
1=success, altered media , 2=success, did not touch media
|
||||
*/
|
||||
int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
@ -2734,24 +2752,56 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
int ret, mode_flag= 0;
|
||||
struct burn_drive_info *dinfo;
|
||||
struct burn_drive *drive;
|
||||
struct burn_progress p;
|
||||
double percent = 1.0;
|
||||
int current_profile;
|
||||
char current_profile_name[80];
|
||||
off_t size= 0;
|
||||
time_t start_time;
|
||||
|
||||
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
||||
"on attempt to -format", 2);
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
|
||||
mode_flag= 4; /* format to full size */
|
||||
burn_disc_get_profile(drive, ¤t_profile, current_profile_name);
|
||||
if(current_profile == 0x14) { /* DVD-RW sequential */
|
||||
size= 128*1024*1024;
|
||||
mode_flag= 1;
|
||||
|
||||
if(current_profile == 0x12) { /* DVD+RAM */
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(flag&1)
|
||||
mode_flag|= (1<<6);
|
||||
|
||||
} else if(current_profile == 0x13) { /* DVD-RW */
|
||||
if(flag&1) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Detected formatted DVD-RW. Thus omitting desired fast format run.");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
return(2);
|
||||
}
|
||||
|
||||
} else if(current_profile == 0x14) { /* DVD-RW sequential */
|
||||
if(flag&1) {
|
||||
size= 128*1024*1024;
|
||||
mode_flag= 1; /* format to size, then write size of zeros */
|
||||
}
|
||||
|
||||
} else if(current_profile == 0x1a) { /* DVD+RW */
|
||||
mode_flag= 2;
|
||||
if(flag&1) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Detected DVD+RW. Thus omitting desired fast format run.");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
return(2);
|
||||
}
|
||||
|
||||
} else if(current_profile == 0x43) { /* BD-RE */
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(flag&1)
|
||||
mode_flag|= (1<<6);
|
||||
|
||||
} else {
|
||||
sprintf(xorriso->info_text,
|
||||
"Can only -format DVD+RW and sequential DVD-RW");
|
||||
"-format: Unsuitable media detected.");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
sprintf(xorriso->info_text,"Media current: %s (%4.4xh)",
|
||||
current_profile_name, current_profile);
|
||||
@ -2768,9 +2818,27 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
Xorriso_info(xorriso, 0);
|
||||
burn_disc_format(drive, size, mode_flag);
|
||||
|
||||
#ifdef NIX
|
||||
|
||||
/* <<< too boring */
|
||||
ret= Xorriso_pacifier_loop(xorriso, drive, 0);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
#else
|
||||
|
||||
start_time= time(0);
|
||||
usleep(1000000);
|
||||
while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) {
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */
|
||||
percent = 1.0 + ((double) p.sector+1.0) / ((double) p.sectors) * 98.0;
|
||||
sprintf(xorriso->info_text, "Formatting ( %.1f%% done in %d seconds)",
|
||||
percent, (int) (time(0) - start_time));
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
|
||||
usleep(1000000);
|
||||
}
|
||||
|
||||
#endif /* ! NIX */
|
||||
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
sprintf(xorriso->info_text, "Formatting done\n");
|
||||
@ -2779,6 +2847,60 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit2= formatting rather than blanking
|
||||
@return 0=failure, did not touch media , -1=failure, altered media
|
||||
1=success, altered media , 2=success, did not touch media
|
||||
*/
|
||||
int Xorriso_blank_as_needed(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
int ret, is_formatted= -1, status, num_formats;
|
||||
struct burn_drive_info *dinfo;
|
||||
struct burn_drive *drive;
|
||||
enum burn_disc_status disc_state;
|
||||
unsigned dummy;
|
||||
int current_profile;
|
||||
char current_profile_name[80];
|
||||
off_t size;
|
||||
|
||||
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
||||
"on attempt to blank or format", 2);
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
|
||||
burn_disc_get_profile(drive, ¤t_profile, current_profile_name);
|
||||
|
||||
ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats);
|
||||
if(ret>0 && status==BURN_FORMAT_IS_FORMATTED)
|
||||
is_formatted= 1;
|
||||
if(current_profile == 0x12 || current_profile == 0x43) { /* DVD+RAM , BD-RE */
|
||||
if(is_formatted<0) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-blank or -format: Unclear formatting status of %s",
|
||||
current_profile_name);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
if(!is_formatted) {
|
||||
ret= Xorriso_format_media(xorriso, 0);
|
||||
return(ret);
|
||||
}
|
||||
} else if(current_profile == 0x14 && (flag&4)) { /* DVD-RW sequential */
|
||||
ret= Xorriso_format_media(xorriso, 0);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
disc_state = isoburn_disc_get_status(drive);
|
||||
if(disc_state != BURN_DISC_BLANK && !(flag&4)) {
|
||||
ret= Xorriso_blank_media(xorriso, 1);
|
||||
return(ret);
|
||||
}
|
||||
sprintf(xorriso->info_text, "%s as_needed: no need for action detected",
|
||||
(flag&4) ? "-format" : "-blank");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
return(2);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error,int flag)
|
||||
{
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
|
Reference in New Issue
Block a user