Completed -tell_media_space, checked space before burn, failed -end exits >0

This commit is contained in:
Thomas Schmitt 2007-10-20 19:48:36 +00:00
parent 9c546c72ba
commit 3ad7245f50
4 changed files with 44 additions and 18 deletions

View File

@ -4469,15 +4469,22 @@ int Xorriso_option_status_history_max(struct XorrisO *xorriso, int num,
/* Option -tell_media_space */
int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag)
{
int ret;
int ret, free_space= 0, media_space= 0;
ret= Xorriso_tell_media_space(xorriso, 0);
ret= Xorriso_tell_media_space(xorriso, &media_space, &free_space, 0);
if(ret<0) {
sprintf(xorriso->info_text, "Cannot -tell_media_space");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
sprintf(xorriso->result_line, "%d\n", ret);
if(free_space<0) {
sprintf(xorriso->info_text,
"Pending image size larger than free space on media");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
}
sprintf(xorriso->result_line, "Write space : %d\n", media_space);
Xorriso_result(xorriso, 0);
sprintf(xorriso->result_line, "Free space : %d\n", free_space);
Xorriso_result(xorriso, 0);
return(1);
}
@ -4688,6 +4695,9 @@ next_command:;
} else if(strcmp(cmd,"-end")==0) {
Xorriso_option_end(xorriso, 0);
ret= Xorriso_eval_problem_status(xorriso, ret, 0);
if(ret<0)
return(ret);
{ret= 3; goto ex;}
} else if(strcmp(cmd,"-f")==0) {

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.10.20.171046"
#define Xorriso_timestamP "2007.10.20.194918"

View File

@ -268,7 +268,7 @@ int Xorriso_make_write_options(
*/
int Xorriso_write_growing(struct XorrisO *xorriso, int flag)
{
int ret;
int ret, media_space;
struct isoburn_source_opts sopts;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
@ -309,15 +309,22 @@ int Xorriso_write_growing(struct XorrisO *xorriso, int flag)
{ret= 0; goto ex;}
}
if(flag&1) {
ret= burn_disc_get_sectors(disc);
goto ex;
}
ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0);
if(ret<=0)
goto ex;
ret= burn_disc_get_sectors(disc);
if(flag&1)
goto ex;
media_space= burn_disc_available_space(drive, burn_options) / (off_t) 2048;
if(media_space < ret) {
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text,"Image size %ds exceeds free space on media %ds",
ret, media_space);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
{ret= 0; goto ex;}
}
isoburn_disc_write(burn_options, disc);
burn_write_opts_free(burn_options);
@ -767,13 +774,16 @@ 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 *media_space, int *free_space, int flag)
{
int ret, free_space;
int ret;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
struct burn_write_opts *burn_options;
(*free_space)= (*media_space)= 0;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to -tell_media_space", 2);
if(ret<=0)
@ -782,15 +792,20 @@ int Xorriso_tell_media_space(struct XorrisO *xorriso, int flag)
ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0);
if(ret<=0)
return(-1);
free_space= burn_disc_available_space(drive, burn_options) / (off_t) 2048;
(*free_space)= (*media_space)=
burn_disc_available_space(drive, burn_options) / (off_t) 2048;
burn_write_opts_free(burn_options);
/* >>> subtract space needed for pending session image */
if(xorriso->volset_change_pending) {
/* >>> care for modifying */
ret= Xorriso_write_growing(xorriso, 1);
if(ret>0)
(*free_space)-= ret;
}
Xorriso_process_msg_queues(xorriso,0);
if(free_space<=0)
free_space= 0;
return(free_space);
return(1);
}

View File

@ -37,7 +37,8 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag);
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 *media_space, int *free_space, int flag);
int Xorriso_blank_media(struct XorrisO *xorriso, int flag);