Implemented a more reasonable solution for drive truncation with regular files

This commit is contained in:
2008-02-21 18:52:52 +00:00
parent 43ea3bdef2
commit 25a68fcf77
8 changed files with 59 additions and 17 deletions

View File

@ -273,6 +273,8 @@ ex:
/**
@param flag bit0= load
bit1= regard overwriteable media as blank
bit2= if the drive is a regular disk file: truncate it to
the write start address
*/
int isoburn_drive_aquire(struct burn_drive_info *drive_infos[],
char *adr, int flag)
@ -298,6 +300,12 @@ int isoburn_drive_aquire(struct burn_drive_info *drive_infos[],
if(ret<=0)
goto ex;
if(flag&4) {
ret= isoburn_find_emulator(&o, (*drive_infos)[0].drive, 0);
if(ret>0 && o!=NULL)
o->truncate= 1;
}
ret= 1;
ex:
if(ret<=0) {
@ -496,10 +504,13 @@ int isoburn_disc_track_lba_nwa(struct burn_drive *d,
void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
{
int ret;
off_t nwa= 0;
struct isoburn *o;
struct burn_drive *drive;
char reasons[BURN_REASONS_LEN],msg[160+BURN_REASONS_LEN];
char adr[BURN_DRIVE_ADR_LEN];
enum burn_write_types write_type;
struct stat stbuf;
drive= burn_write_opts_get_drive(opts);
ret= isoburn_find_emulator(&o, drive, 0);
@ -509,8 +520,10 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
o->wrote_well= -1;
if(o->emulation_mode!=0) {
burn_write_opts_set_multi(opts, 0);
if(o->emulation_mode>0 && o->nwa >= 0)
if(o->emulation_mode>0 && o->nwa >= 0) {
burn_write_opts_set_start_byte(opts, ((off_t) o->nwa) * (off_t) 2048);
nwa= o->nwa;
}
}
}
@ -539,6 +552,19 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
((off_t) Hardcoded_cd_rw_nwA) * (off_t) 2048);
#endif
if(o->truncate) {
ret= burn_drive_get_drive_role(drive);
if(ret==2) {
ret= burn_drive_d_get_adr(drive, adr);
if(ret>0) {
ret= lstat(adr, &stbuf);
if(ret!=-1)
if(S_ISREG(stbuf.st_mode))
truncate(adr, nwa * (off_t) 2048);
}
}
}
burn_disc_write(opts, disc);
}

View File

@ -69,6 +69,7 @@ int isoburn_new(struct isoburn **objpt, int flag)
o->emulation_mode= 0;
o->min_start_byte= 0;
o->nwa= 0;
o->truncate= 0;
#ifdef Libisoburn_no_fifO
o->iso_source= NULL;

View File

@ -42,8 +42,12 @@ struct isoburn {
/* Aligned start address to be used for processing (counted in blocks) */
int nwa;
/* Truncate to .nwa an eventual regular file serving as output drive */
int truncate;
/* Eventual freely fabricated isoburn_disc_get_status().
BURN_DISC_UNREADY means that normally emulated status is in effect.
BURN_DISC_UNREADY means that this variable is disabled
and normally emulated status is in effect.
*/
enum burn_disc_status fabricated_disc_status;

View File

@ -328,7 +328,8 @@ int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
@param flag bit0= attempt to load the disc tray.
Else: failure if not loaded.
bit1= regard overwriteable media as blank
bit2= if the drive is a regular disk file: truncate it to
the write start address
@return 1 = success , 0 = drive not found , <0 = other error
*/
int isoburn_drive_aquire(struct burn_drive_info *drive_infos[],