-- see zlib.h -- */
(file)
| 628 | |
| 629 | /* -- see zlib.h -- */ |
| 630 | int ZEXPORT gzclose_w(file) |
| 631 | gzFile file; |
| 632 | { |
| 633 | int ret = Z_OK; |
| 634 | gz_statep state; |
| 635 | |
| 636 | /* get internal structure */ |
| 637 | if (file == NULL) |
| 638 | return Z_STREAM_ERROR; |
| 639 | state = (gz_statep)file; |
| 640 | |
| 641 | /* check that we're writing */ |
| 642 | if (state->mode != GZ_WRITE) |
| 643 | return Z_STREAM_ERROR; |
| 644 | |
| 645 | /* check for seek request */ |
| 646 | if (state->seek) { |
| 647 | state->seek = 0; |
| 648 | if (gz_zero(state, state->skip) == -1) |
| 649 | ret = state->err; |
| 650 | } |
| 651 | |
| 652 | /* flush, free memory, and close file */ |
| 653 | if (gz_comp(state, Z_FINISH) == -1) |
| 654 | ret = state->err; |
| 655 | if (state->size) { |
| 656 | if (!state->direct) { |
| 657 | (void)deflateEnd(&(state->strm)); |
| 658 | free(state->out); |
| 659 | } |
| 660 | free(state->in); |
| 661 | } |
| 662 | gz_error(state, Z_OK, NULL); |
| 663 | free(state->path); |
| 664 | if (close(state->fd) == -1) |
| 665 | ret = Z_ERRNO; |
| 666 | free(state); |
| 667 | return ret; |
| 668 | } |