New API function isoburn_disc_available_space() fixes bug with DVD+RW capacity

This commit is contained in:
Thomas Schmitt 2008-02-09 10:08:40 +00:00
parent 30c30bd286
commit 5a24e5b708
5 changed files with 39 additions and 7 deletions

View File

@ -399,6 +399,22 @@ void isoburn_disc_erase(struct burn_drive *drive, int fast)
} }
off_t isoburn_disc_available_space(struct burn_drive *d,
struct burn_write_opts *opts)
{
int ret;
struct isoburn *o;
off_t avail;
ret= isoburn_find_emulator(&o, d, 0);
if(ret>0 && o!=NULL)
if(o->emulation_mode!=0)
burn_write_opts_set_start_byte(opts, ((off_t) o->nwa) * (off_t) 2048);
avail= burn_disc_available_space(d, opts);
return(avail);
}
int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba) int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba)
{ {
int ret; int ret;

View File

@ -654,6 +654,21 @@ int isoburn_set_read_pacifier(struct burn_drive *drive,
int isoburn_attach_image(struct burn_drive *d, IsoImage *image); int isoburn_attach_image(struct burn_drive *d, IsoImage *image);
/** Return the best possible estimation of the currently available capacity of
the media. This might depend on particular write option settings and on
drive state.
An eventual start address for emulated multi-session will be subtracted
from the capacity estimation given by burn_disc_available_space().
Negative results get defaulted to 0.
Wrapper for: burn_disc_available_space()
@param d The drive to query.
@param o If not NULL: write parameters to be set on drive before query
@return number of most probably available free bytes
*/
off_t isoburn_disc_available_space(struct burn_drive *d,
struct burn_write_opts *o);
/** Obtain the start block number of the most recent session on media. In /** Obtain the start block number of the most recent session on media. In
case of random access media this will always be 0. Succesfull return is case of random access media this will always be 0. Succesfull return is
not a guarantee that there is a ISO-9660 image at all. The call will fail, not a guarantee that there is a ISO-9660 image at all. The call will fail,

View File

@ -6711,6 +6711,7 @@ int Xorriso_option_end(struct XorrisO *xorriso, int flag)
xorriso->volset_change_pending= 0; xorriso->volset_change_pending= 0;
} else { } else {
ret= Xorriso_option_commit(xorriso, 1); ret= Xorriso_option_commit(xorriso, 1);
xorriso->volset_change_pending= 0; /* no further tries to commit */
if(ret<=0) if(ret<=0)
return(ret); return(ret);
} }
@ -7871,7 +7872,7 @@ int Xorriso_option_print_size(struct XorrisO *xorriso, int flag)
if(!xorriso->volset_change_pending) { if(!xorriso->volset_change_pending) {
sprintf(xorriso->info_text,"-print-size: No image modifications pending"); sprintf(xorriso->info_text,"-print-size: No image modifications pending");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
sprintf(xorriso->result_line,"Image size : 0\n"); sprintf(xorriso->result_line,"Image size : 0s\n");
Xorriso_result(xorriso,0); Xorriso_result(xorriso,0);
return(2); return(2);
} }
@ -7881,7 +7882,7 @@ int Xorriso_option_print_size(struct XorrisO *xorriso, 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);
} }
sprintf(xorriso->result_line,"Image size : %d\n", ret); sprintf(xorriso->result_line,"Image size : %ds\n", ret);
Xorriso_result(xorriso,0); Xorriso_result(xorriso,0);
return(1); return(1);
} }
@ -8175,9 +8176,9 @@ int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag)
"Pending image size larger than free space on media"); "Pending image size larger than free space on media");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
} }
sprintf(xorriso->result_line, "Media space : %d\n", media_space); sprintf(xorriso->result_line, "Media space : %ds\n", media_space);
Xorriso_result(xorriso, 0); Xorriso_result(xorriso, 0);
sprintf(xorriso->result_line, "Free space : %d\n", free_space); sprintf(xorriso->result_line, "After commit : %ds\n", free_space);
Xorriso_result(xorriso, 0); Xorriso_result(xorriso, 0);
return(1); return(1);
} }

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.02.09.092805" #define Xorriso_timestamP "2008.02.09.100750"

View File

@ -813,7 +813,7 @@ no_track:;
burn_track_define_data(tracks[0], 0, padding * 2048, 0, BURN_MODE1); burn_track_define_data(tracks[0], 0, padding * 2048, 0, BURN_MODE1);
Xorriso_process_msg_queues(xorriso,0); Xorriso_process_msg_queues(xorriso,0);
media_space= burn_disc_available_space(drive, burn_options) / (off_t) 2048; media_space= isoburn_disc_available_space(drive, burn_options) / (off_t) 2048;
if(media_space < img_sectors + padding) { if(media_space < img_sectors + padding) {
Xorriso_process_msg_queues(xorriso,0); Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text,"Image size %ds exceeds free space on media %ds", sprintf(xorriso->info_text,"Image size %ds exceeds free space on media %ds",
@ -1900,7 +1900,7 @@ int Xorriso_tell_media_space(struct XorrisO *xorriso,
if(ret<=0) if(ret<=0)
return(-1); return(-1);
(*free_space)= (*media_space)= (*free_space)= (*media_space)=
burn_disc_available_space(drive, burn_options) / (off_t) 2048; isoburn_disc_available_space(drive, burn_options) / (off_t) 2048;
burn_write_opts_free(burn_options); burn_write_opts_free(burn_options);
if(xorriso->volset_change_pending) { if(xorriso->volset_change_pending) {