Implemented option -tell_media_space

This commit is contained in:
Thomas Schmitt 2007-10-18 18:32:32 +00:00
parent 499b98b96f
commit d4216fe27e
4 changed files with 96 additions and 35 deletions

View File

@ -4342,7 +4342,16 @@ int Xorriso_option_status_history_max(struct XorrisO *xorriso, int num,
/* Option -tell_media_space */ /* Option -tell_media_space */
int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag) int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag)
{ {
fprintf(stderr, ">>> LIBISOBURN : -tell_media_space\n"); int ret;
ret= Xorriso_tell_media_space(xorriso, 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);
Xorriso_result(xorriso, 0);
return(1); return(1);
} }

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.10.18.171415" #define Xorriso_timestamP "2007.10.18.183200"

View File

@ -96,6 +96,27 @@ int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag)
} }
/* @param flag bit1= obtain outdrive, else indrive */
int Xorriso_get_drive_handles(struct XorrisO *xorriso,
struct burn_drive_info **dinfo,
struct burn_drive **drive,
char *attempt, int flag)
{
if(flag&2)
*dinfo= (struct burn_drive_info *) xorriso->out_drive_handle;
else
*dinfo= (struct burn_drive_info *) xorriso->in_drive_handle;
if(*dinfo==NULL) {
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "No drive aquired %s", attempt);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
*drive= (*dinfo)[0].drive;
return(1);
}
/* @param flag bit0=aquire as isoburn input drive /* @param flag bit0=aquire as isoburn input drive
bit1=aquire as libburn output drive (as isoburn drive if bit0) bit1=aquire as libburn output drive (as isoburn drive if bit0)
*/ */
@ -185,8 +206,8 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
in_is_out_too= (xorriso->in_drive_handle == xorriso->out_drive_handle); in_is_out_too= (xorriso->in_drive_handle == xorriso->out_drive_handle);
if((flag&1) && xorriso->in_drive_handle != NULL) { if((flag&1) && xorriso->in_drive_handle != NULL) {
dinfo= (struct burn_drive_info *) xorriso->in_drive_handle; Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
drive= dinfo[0].drive; "on attempt to give drive up", 0);
isoburn_drive_release(drive,0); isoburn_drive_release(drive,0);
iso_volset_free((struct iso_volset *) xorriso->in_volset_handle); iso_volset_free((struct iso_volset *) xorriso->in_volset_handle);
@ -202,18 +223,36 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
} }
} }
if((flag&2) && xorriso->out_drive_handle!=NULL) { if((flag&2) && xorriso->out_drive_handle!=NULL) {
dinfo= (struct burn_drive_info *) xorriso->out_drive_handle; Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
drive= dinfo[0].drive; "on attempt to give drive up", 2);
isoburn_drive_release(drive,0); isoburn_drive_release(drive,0);
burn_drive_info_free(dinfo); burn_drive_info_free(dinfo);
xorriso->out_drive_handle= NULL; xorriso->out_drive_handle= NULL;
} }
Xorriso_process_msg_queues(xorriso,0); Xorriso_process_msg_queues(xorriso,0);
return(1); return(1);
} }
int Xorriso_make_write_options(
struct XorrisO *xorriso, struct burn_drive *drive,
struct burn_write_opts **burn_options, int flag)
{
*burn_options= burn_write_opts_new(drive);
if(*burn_options==NULL) {
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text,"Cannot allocate option set");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
burn_write_opts_set_simulate(*burn_options, !!xorriso->do_dummy);
burn_write_opts_set_multi(*burn_options, !xorriso->do_close);
burn_drive_set_speed(drive, xorriso->speed, xorriso->speed);
burn_write_opts_set_underrun_proof(*burn_options, 1);
return(1);
}
int Xorriso_write_growing(struct XorrisO *xorriso, int flag) int Xorriso_write_growing(struct XorrisO *xorriso, int flag)
{ {
int ret; int ret;
@ -223,13 +262,10 @@ int Xorriso_write_growing(struct XorrisO *xorriso, int flag)
struct burn_disc *disc; struct burn_disc *disc;
struct burn_write_opts *burn_options; struct burn_write_opts *burn_options;
dinfo= (struct burn_drive_info *) xorriso->in_drive_handle; ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
if(dinfo==NULL) { "on attempt to write", 2);
sprintf(xorriso->info_text,"No drive aquired on attempt to write"); if(ret<=0)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0); return(0);
}
drive= dinfo[0].drive;
sopts.level= 2; sopts.level= 2;
sopts.flags= ECMA119_ROCKRIDGE; sopts.flags= ECMA119_ROCKRIDGE;
@ -260,17 +296,9 @@ int Xorriso_write_growing(struct XorrisO *xorriso, int flag)
return(0); return(0);
} }
burn_options= burn_write_opts_new(drive); ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0);
if(burn_options==NULL) { if(ret<=0)
Xorriso_process_msg_queues(xorriso,0); return(ret);
sprintf(xorriso->info_text,"Cannot allocate option set");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
burn_write_opts_set_simulate(burn_options, !!xorriso->do_dummy);
burn_write_opts_set_multi(burn_options, !xorriso->do_close);
burn_drive_set_speed(drive, xorriso->speed, xorriso->speed);
burn_write_opts_set_underrun_proof(burn_options, 1);
isoburn_disc_write(burn_options, disc); isoburn_disc_write(burn_options, disc);
burn_write_opts_free(burn_options); burn_write_opts_free(burn_options);
@ -339,10 +367,11 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
Xorriso_process_msg_queues(xorriso,0); Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text,"No volset is loaded."); sprintf(xorriso->info_text,"No volset is loaded.");
if(xorriso->indev[0]==0) if(xorriso->indev[0]==0)
sprintf(xorriso->info_text," No -dev or -indev is selected."); sprintf(xorriso->info_text+strlen(xorriso->info_text),
" No -dev or -indev is selected.");
else else
sprintf(xorriso->info_text," Possible program error with drive '%s'.", sprintf(xorriso->info_text+strlen(xorriso->info_text),
xorriso->indev); " Possible program error with drive '%s'.", xorriso->indev);
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);
@ -514,15 +543,10 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
struct burn_drive *drive; struct burn_drive *drive;
enum burn_disc_status s; enum burn_disc_status s;
dinfo= (struct burn_drive_info *) xorriso->in_drive_handle; ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
if(dinfo==NULL) { "on attempt to print Table Of Content", 2);
Xorriso_process_msg_queues(xorriso,0); if(ret<=0)
sprintf(xorriso->info_text,
"No drive aquired on attempt to print Table Of Content");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0); return(0);
}
drive= dinfo[0].drive;
respt= xorriso->result_line; respt= xorriso->result_line;
@ -695,3 +719,29 @@ int Xorriso_show_devices(struct XorrisO *xorriso, int flag)
} }
int Xorriso_tell_media_space(struct XorrisO *xorriso, int flag)
{
int ret, free_space;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
struct burn_write_opts *burn_options;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to -tell_media_space", 2);
if(ret<=0)
return(0);
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;
burn_write_opts_free(burn_options);
/* >>> subtract space needed for pending session image */
if(free_space<=0)
free_space= 0;
return(free_space);
}

View File

@ -37,6 +37,8 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag);
int Xorriso_show_devices(struct XorrisO *xorriso, int flag); int Xorriso_show_devices(struct XorrisO *xorriso, int flag);
int Xorriso_tell_media_space(struct XorrisO *xorriso, int flag);
#endif /* Xorrisoburn_includeD */ #endif /* Xorrisoburn_includeD */