Fix chdman -update to leave the write protect state alone when updating
uncompressed CHDs. [Michael Zapf]
This commit is contained in:
parent
6564c7b398
commit
6a36bae504
@ -1448,7 +1448,7 @@ chd_error chd_compress_hunk(chd_file *chd, const void *data, double *curratio)
|
||||
a CHD
|
||||
-------------------------------------------------*/
|
||||
|
||||
chd_error chd_compress_finish(chd_file *chd)
|
||||
chd_error chd_compress_finish(chd_file *chd, int write_protect)
|
||||
{
|
||||
/* error if in the wrong state */
|
||||
if (!chd->compressing)
|
||||
@ -1461,7 +1461,8 @@ chd_error chd_compress_finish(chd_file *chd)
|
||||
metadata_compute_hash(chd, chd->header.rawsha1, chd->header.sha1);
|
||||
|
||||
/* turn off the writeable flag and re-write the header */
|
||||
chd->header.flags &= ~CHDFLAGS_IS_WRITEABLE;
|
||||
if (chd->header.compression != CHDCOMPRESSION_NONE || write_protect)
|
||||
chd->header.flags &= ~CHDFLAGS_IS_WRITEABLE;
|
||||
chd->compressing = FALSE;
|
||||
return header_write(chd->file, &chd->header);
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ chd_error chd_compress_begin(chd_file *chd);
|
||||
chd_error chd_compress_hunk(chd_file *chd, const void *data, double *curratio);
|
||||
|
||||
/* finish compressing data to a CHD */
|
||||
chd_error chd_compress_finish(chd_file *chd);
|
||||
chd_error chd_compress_finish(chd_file *chd, int write_protect);
|
||||
|
||||
|
||||
|
||||
|
@ -656,7 +656,7 @@ static int do_createcd(int argc, char *argv[], int param)
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
err = chd_compress_finish(chd);
|
||||
err = chd_compress_finish(chd, TRUE);
|
||||
if (err != CHDERR_NONE)
|
||||
fprintf(stderr, "Error during compression finalization: %s\n", chd_error_string(err));
|
||||
else
|
||||
@ -1055,7 +1055,7 @@ static int do_createav(int argc, char *argv[], int param)
|
||||
}
|
||||
|
||||
/* finish compression */
|
||||
err = chd_compress_finish(chd);
|
||||
err = chd_compress_finish(chd, TRUE);
|
||||
if (err != CHDERR_NONE)
|
||||
goto cleanup;
|
||||
else
|
||||
@ -2874,7 +2874,7 @@ static chd_error chdman_compress_file(chd_file *chd, const char *rawfile, UINT32
|
||||
}
|
||||
|
||||
/* finish compression */
|
||||
err = chd_compress_finish(chd);
|
||||
err = chd_compress_finish(chd, TRUE);
|
||||
if (err != CHDERR_NONE)
|
||||
goto cleanup;
|
||||
|
||||
@ -3031,7 +3031,7 @@ static chd_error chdman_compress_chd(chd_file *chd, chd_file *source, UINT32 tot
|
||||
}
|
||||
|
||||
/* finish compression */
|
||||
err = chd_compress_finish(chd);
|
||||
err = chd_compress_finish(chd, !(source_header->flags & CHDFLAGS_IS_WRITEABLE));
|
||||
if (err != CHDERR_NONE)
|
||||
goto cleanup;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user