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);
}