mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-12-27 06:29:19 +00:00
Fix commentary and ignore expected_bytes if set to zero
This commit is contained in:
parent
ff204a4300
commit
5a9770829e
@ -51,11 +51,12 @@ static const char* const _gzerr(gzFile gzf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compress from file source to file dest until EOF on source.
|
/* Compress some_file to some_file.gz and unlink previous.
|
||||||
def() returns Z_OK on success, Z_MEM_ERROR if memory could not be allocated
|
*
|
||||||
for processing, Z_VERSION_ERROR if the version of zlib.h and the version of
|
* If expected_bytecount > 0, check that byte count written matches expected.
|
||||||
the library linked do not match, or Z_ERRNO if there is an error reading or
|
*
|
||||||
writing the files. */
|
* Return NULL on success, or error string (possibly from zlib) on failure.
|
||||||
|
*/
|
||||||
const char *zlib_deflate(const char* const src, const int expected_bytecount) {
|
const char *zlib_deflate(const char* const src, const int expected_bytecount) {
|
||||||
unsigned char buf[CHUNK];
|
unsigned char buf[CHUNK];
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
@ -114,7 +115,7 @@ const char *zlib_deflate(const char* const src, const int expected_bytecount) {
|
|||||||
|
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
if (bytecount != expected_bytecount) {
|
if (expected_bytecount && bytecount != expected_bytecount) {
|
||||||
ERRLOG("OOPS did not write expected_bytecount of %d ... apparently wrote %d", expected_bytecount, bytecount);
|
ERRLOG("OOPS did not write expected_bytecount of %d ... apparently wrote %d", expected_bytecount, bytecount);
|
||||||
if (gzdest) {
|
if (gzdest) {
|
||||||
err = (char *)_gzerr(gzdest);
|
err = (char *)_gzerr(gzdest);
|
||||||
@ -141,12 +142,12 @@ const char *zlib_deflate(const char* const src, const int expected_bytecount) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decompress from file source to file dest until stream ends or EOF.
|
/* Decompress some_file.gz to some_file and unlink previous.
|
||||||
inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be
|
*
|
||||||
allocated for processing, Z_DATA_ERROR if the deflate data is
|
* If expected_bytecount > 0, check that byte count read matches expected.
|
||||||
invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
|
*
|
||||||
the version of the library linked do not match, or Z_ERRNO if there
|
* Return NULL on success, or error string (possibly from zlib) on failure.
|
||||||
is an error reading or writing the files. */
|
*/
|
||||||
const char *zlib_inflate(const char* const src, const int expected_bytecount) {
|
const char *zlib_inflate(const char* const src, const int expected_bytecount) {
|
||||||
gzFile gzsource = NULL;
|
gzFile gzsource = NULL;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
@ -214,7 +215,7 @@ const char *zlib_inflate(const char* const src, const int expected_bytecount) {
|
|||||||
|
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
if (bytecount != expected_bytecount) {
|
if (expected_bytecount && bytecount != expected_bytecount) {
|
||||||
ERRLOG("OOPS did not write expected_bytecount of %d ... apparently wrote %d", expected_bytecount, bytecount);
|
ERRLOG("OOPS did not write expected_bytecount of %d ... apparently wrote %d", expected_bytecount, bytecount);
|
||||||
if (gzsource) {
|
if (gzsource) {
|
||||||
err = (char *)_gzerr(gzsource);
|
err = (char *)_gzerr(gzsource);
|
||||||
|
Loading…
Reference in New Issue
Block a user