diff options
| -rw-r--r-- | gzread.c | 5 | ||||
| -rw-r--r-- | zlib.h | 15 |
2 files changed, 17 insertions, 3 deletions
| @@ -553,7 +553,7 @@ int ZEXPORT gzdirect(file) | |||
| 553 | int ZEXPORT gzclose_r(file) | 553 | int ZEXPORT gzclose_r(file) |
| 554 | gzFile file; | 554 | gzFile file; |
| 555 | { | 555 | { |
| 556 | int ret; | 556 | int ret, err; |
| 557 | gz_statep state; | 557 | gz_statep state; |
| 558 | 558 | ||
| 559 | /* get internal structure */ | 559 | /* get internal structure */ |
| @@ -571,9 +571,10 @@ int ZEXPORT gzclose_r(file) | |||
| 571 | free(state->out); | 571 | free(state->out); |
| 572 | free(state->in); | 572 | free(state->in); |
| 573 | } | 573 | } |
| 574 | err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; | ||
| 574 | gz_error(state, Z_OK, NULL); | 575 | gz_error(state, Z_OK, NULL); |
| 575 | free(state->path); | 576 | free(state->path); |
| 576 | ret = close(state->fd); | 577 | ret = close(state->fd); |
| 577 | free(state); | 578 | free(state); |
| 578 | return ret ? Z_ERRNO : Z_OK; | 579 | return ret ? Z_ERRNO : err; |
| 579 | } | 580 | } |
| @@ -1297,6 +1297,18 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | |||
| 1297 | If something other than a gzip stream is encountered after a gzip stream, | 1297 | If something other than a gzip stream is encountered after a gzip stream, |
| 1298 | that remaining trailing garbage is ignored (and no error is returned). | 1298 | that remaining trailing garbage is ignored (and no error is returned). |
| 1299 | 1299 | ||
| 1300 | gzread can be used to read a gzip file that is being concurrently written. | ||
| 1301 | Upon reaching the end of the input, gzread will return with the available | ||
| 1302 | data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then | ||
| 1303 | gzclearerr can be used to clear the end of file indicator in order to permit | ||
| 1304 | gzread to be tried again. Z_OK indicates that a gzip stream was completed | ||
| 1305 | on the last gzread. Z_BUF_ERROR indicates that the input file ended in the | ||
| 1306 | middle of a gzip stream. Note that gzread does not return -1 in the event | ||
| 1307 | of an incomplete gzip stream. This error is deferred until gzclose(), which | ||
| 1308 | will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip | ||
| 1309 | stream. Alternatively, gzerror can be used before gzclose to detect this | ||
| 1310 | case. | ||
| 1311 | |||
| 1300 | gzread returns the number of uncompressed bytes actually read, less than | 1312 | gzread returns the number of uncompressed bytes actually read, less than |
| 1301 | len for end of file, or -1 for error. | 1313 | len for end of file, or -1 for error. |
| 1302 | */ | 1314 | */ |
| @@ -1480,7 +1492,8 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); | |||
| 1480 | must not be called more than once on the same allocation. | 1492 | must not be called more than once on the same allocation. |
| 1481 | 1493 | ||
| 1482 | gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a | 1494 | gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a |
| 1483 | file operation error, Z_MEM_ERROR if out of memory, or Z_OK on success. | 1495 | file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the |
| 1496 | last read ended in the middle of a gzip stream, or Z_OK on success. | ||
| 1484 | */ | 1497 | */ |
| 1485 | 1498 | ||
| 1486 | ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); | 1499 | ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); |
