Implement fixed write function

This commit is contained in:
shermp
2019-06-10 09:08:41 +12:00
parent cfcbca05dd
commit 00a736dc75
2 changed files with 14 additions and 0 deletions

View File

@@ -98,4 +98,15 @@ int mvhd_diff_read(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff)
buff += MVHD_SECTOR_SIZE;
}
return truncated_sectors;
}
int mvhd_fixed_write(MVHDMeta* vhdm, int offset, int num_sectors, void* in_buff) {
int64_t addr;
int transfer_sectors, truncated_sectors;
int total_sectors = vhdm->footer.geom.cyl * vhdm->footer.geom.heads * vhdm->footer.geom.spt;
mvhd_check_sectors(offset, num_sectors, total_sectors, &transfer_sectors, &truncated_sectors);
addr = (int64_t)offset * MVHD_SECTOR_SIZE;
fseeko64(vhdm->f, addr, SEEK_SET);
fwrite(in_buff, transfer_sectors*MVHD_SECTOR_SIZE, 1, vhdm->f);
return truncated_sectors;
}

View File

@@ -6,4 +6,7 @@ int mvhd_fixed_read(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff)
int mvhd_sparse_read(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff);
int mvhd_diff_read(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff);
int mvhd_fixed_write(MVHDMeta* vhdm, int offset, int num_sectors, void* in_buff);
int mvhd_sparse_diff_write(MVHDMeta* vhdm, int offset, int num_sectors, void* in_buff);
#endif