summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-08-02 22:01:47 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-08-02 22:01:47 +0000
commit6a36bae5045d2d08ff779948fbddbbcdc9cb7442 (patch)
treedb54db853a775e04f91ef5087161d4a70d237435
parent6564c7b398079a05ba9153dda0adae2939b40e22 (diff)
Fix chdman -update to leave the write protect state alone when updating
uncompressed CHDs. [Michael Zapf]
-rw-r--r--src/lib/util/chd.c5
-rw-r--r--src/lib/util/chd.h2
-rw-r--r--src/tools/chdman.c8
3 files changed, 8 insertions, 7 deletions
diff --git a/src/lib/util/chd.c b/src/lib/util/chd.c
index a8e9930dfe3..94f209a354a 100644
--- a/src/lib/util/chd.c
+++ b/src/lib/util/chd.c
@@ -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);
}
diff --git a/src/lib/util/chd.h b/src/lib/util/chd.h
index 4a6719a21c4..491839aeaf8 100644
--- a/src/lib/util/chd.h
+++ b/src/lib/util/chd.h
@@ -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);
diff --git a/src/tools/chdman.c b/src/tools/chdman.c
index 8165710ab4f..d835fd6445a 100644
--- a/src/tools/chdman.c
+++ b/src/tools/chdman.c
@@ -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;