Implemented option -blank

This commit is contained in:
Thomas Schmitt 2007-10-19 20:41:34 +00:00
parent 8495cefa52
commit 00eba3c5d6
6 changed files with 132 additions and 15 deletions

View File

@ -3156,11 +3156,46 @@ int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag)
} }
/* Option -blank */ /* Option -blank and -format */
/* @param flag bit0= format rather than blank */
int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag) int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag)
{ {
fprintf(stderr, ">>> LIBISOBURN : would perform -blank %s on %s", char drive_name[SfileadrL], *cmd= "-blank";
mode, xorriso->indev); int ret, aq_flag= 2, mode_flag;
if(flag&1)
cmd= "-format";
if(xorriso->out_drive_handle == NULL) {
sprintf(xorriso->info_text,
"%s: No output drive set by -dev -or -outdev", cmd);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
if(xorriso->in_drive_handle == xorriso->out_drive_handle) {
if(xorriso->volset_change_pending) {
sprintf(xorriso->info_text,
"%s: Image changes pending. -commit or -rollback first.", cmd);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
aq_flag= 3;
}
if(strcmp(mode, "all")==0 || strcmp(mode, "full")==0)
mode_flag= 0;
else
mode_flag= 1;
if(flag&1)
ret= Xorriso_format_media(xorriso, mode_flag);
else
ret= Xorriso_blank_media(xorriso, mode_flag);
strcpy(drive_name, xorriso->outdev);
Xorriso_give_up_drive(xorriso, aq_flag);
if(ret<=0)
return(ret);
ret= Xorriso_aquire_drive(xorriso, drive_name, aq_flag);
if(ret<=0)
return(ret);
return(1); return(1);
} }
@ -3433,10 +3468,6 @@ int Xorriso_option_dev(struct XorrisO *xorriso, char *adr, int flag)
ret= Xorriso_aquire_drive(xorriso, adr, flag&3); ret= Xorriso_aquire_drive(xorriso, adr, flag&3);
if(ret<0) if(ret<0)
return(ret); return(ret);
if(Sfile_str(xorriso->indev, adr, 0)<=0)
return(-1);
if(Sfile_str(xorriso->outdev, adr, 0)<=0)
return(-1);
return(1); return(1);
} }
@ -4626,6 +4657,10 @@ next_command:;
(*idx)++; (*idx)++;
ret= Xorriso_option_findx(xorriso, arg1, 0); ret= Xorriso_option_findx(xorriso, arg1, 0);
} else if(strcmp(cmd,"-format")==0) {
(*idx)++;
ret= Xorriso_option_blank(xorriso, arg1, 1);
} else if(strcmp(cmd,"-fs")==0) { } else if(strcmp(cmd,"-fs")==0) {
(*idx)++; (*idx)++;
ret= Xorriso_option_fs(xorriso, arg1, 0); ret= Xorriso_option_fs(xorriso, arg1, 0);

View File

@ -133,7 +133,8 @@ int Xorriso_option_slater_date(struct XorrisO *xorriso,
/* Option -ban_stdio_write */ /* Option -ban_stdio_write */
int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag); int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag);
/* Option -blank */ /* Option -blank and -format */
/* @param flag bit0= format rather than blank */
int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag); int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag);
/* Option -cd alias -cdi */ /* Option -cd alias -cdi */
@ -191,15 +192,15 @@ int Xorriso_option_end(struct XorrisO *xorriso, int flag);
/* Option -f */ /* Option -f */
int Xorriso_option_f(struct XorrisO *xorriso, int flag); int Xorriso_option_f(struct XorrisO *xorriso, int flag);
/* Option -fs */
int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag);
/* Option -find alias -findi */ /* Option -find alias -findi */
int Xorriso_option_findi(struct XorrisO *xorriso, char *pattern, int flag); int Xorriso_option_findi(struct XorrisO *xorriso, char *pattern, int flag);
/* Option -findx */ /* Option -findx */
int Xorriso_option_findx(struct XorrisO *xorriso, char *pattern, int flag); int Xorriso_option_findx(struct XorrisO *xorriso, char *pattern, int flag);
/* Option -fs */
int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag);
/* Option -gid */ /* Option -gid */
int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag); int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag);

View File

@ -183,6 +183,7 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag); int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag);
int Sfile_str(char target[SfileadrL], char *source, int flag);
#endif /* Xorriso_private_includeD */ #endif /* Xorriso_private_includeD */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.10.19.173547" #define Xorriso_timestamP "2007.10.19.204155"

View File

@ -147,11 +147,16 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0); return(0);
} }
if(flag&2) if(flag&2) {
xorriso->out_drive_handle= dinfo; xorriso->out_drive_handle= dinfo;
if(flag&1) if(Sfile_str(xorriso->indev, adr, 0)<=0)
return(-1);
}
if(flag&1) {
xorriso->in_drive_handle= dinfo; xorriso->in_drive_handle= dinfo;
else if(Sfile_str(xorriso->outdev, adr, 0)<=0)
return(-1);
} else
return(1); return(1);
drive= dinfo[0].drive; drive= dinfo[0].drive;
@ -234,6 +239,7 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
if(dinfo!=NULL) if(dinfo!=NULL)
burn_drive_info_free(dinfo); burn_drive_info_free(dinfo);
xorriso->out_drive_handle= NULL; xorriso->out_drive_handle= NULL;
xorriso->outdev[0]= 0;
} }
Xorriso_process_msg_queues(xorriso,0); Xorriso_process_msg_queues(xorriso,0);
return(1); return(1);
@ -755,8 +761,78 @@ int Xorriso_tell_media_space(struct XorrisO *xorriso, int flag)
/* >>> subtract space needed for pending session image */ /* >>> subtract space needed for pending session image */
Xorriso_process_msg_queues(xorriso,0);
if(free_space<=0) if(free_space<=0)
free_space= 0; free_space= 0;
return(free_space); return(free_space);
} }
/* @param flag bit0=fast */
int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
{
int ret;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
enum burn_disc_status disc_state;
struct burn_progress p;
double percent = 1.0;
int current_profile;
char current_profile_name[80];
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to -blank", 2);
if(ret<=0)
return(0);
burn_disc_get_profile(drive, &current_profile, current_profile_name);
/* >>> */;
disc_state = isoburn_disc_get_status(drive);
if(current_profile == 0x13) {
; /* formatted DVD-RW will get blanked to sequential state */
} else if(disc_state == BURN_DISC_BLANK) {
sprintf(xorriso->info_text,"Blank media detected. Will leave it untouched");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return 2;
} else if(disc_state==BURN_DISC_FULL || disc_state==BURN_DISC_APPENDABLE) {
;
} else if(disc_state == BURN_DISC_EMPTY) {
sprintf(xorriso->info_text,"No media detected in drive");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return 0;
} else {
sprintf(xorriso->info_text, "Unsuitable drive and media state");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return 0;
}
if(!isoburn_disc_erasable(drive)) {
sprintf(xorriso->info_text, "Media is not of erasable type");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return 0;
}
sprintf(xorriso->info_text, "Beginning to %s-blank media.\n",
((flag&1)?"fast":"full"));
Xorriso_info(xorriso,0);
isoburn_disc_erase(drive, (flag&1));
usleep(1000000);
while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) {
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);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
usleep(1000000);
}
sprintf(xorriso->info_text, "Blanking done\n");
Xorriso_info(xorriso,0);
return(1);
}
int Xorriso_format_media(struct XorrisO *xorriso, int flag)
{
fprintf(stderr, ">>> XORRISO : -format not implemented yet\n");
return(1);
}

View File

@ -39,6 +39,10 @@ int Xorriso_show_devices(struct XorrisO *xorriso, int flag);
int Xorriso_tell_media_space(struct XorrisO *xorriso, int flag); int Xorriso_tell_media_space(struct XorrisO *xorriso, int flag);
int Xorriso_blank_media(struct XorrisO *xorriso, int flag);
int Xorriso_format_media(struct XorrisO *xorriso, int flag);
#endif /* Xorrisoburn_includeD */ #endif /* Xorrisoburn_includeD */