| 855 | } |
| 856 | |
| 857 | int read(void *buf, int len) |
| 858 | { |
| 859 | if(!reading || !buf || !len) return 0; |
| 860 | zfile.next_out = (Bytef *)buf; |
| 861 | zfile.avail_out = len; |
| 862 | while(zfile.avail_out > 0) |
| 863 | { |
| 864 | if(!zfile.avail_in) |
| 865 | { |
| 866 | readbuf(BUFSIZE); |
| 867 | if(!zfile.avail_in) { stopreading(); break; } |
| 868 | } |
| 869 | int err = inflate(&zfile, Z_NO_FLUSH); |
| 870 | if(err == Z_STREAM_END) { crc = crc32(crc, (Bytef *)buf, len - zfile.avail_out); finishreading(); stopreading(); return len - zfile.avail_out; } |
| 871 | else if(err != Z_OK) { stopreading(); break; } |
| 872 | } |
| 873 | crc = crc32(crc, (Bytef *)buf, len - zfile.avail_out); |
| 874 | return len - zfile.avail_out; |
| 875 | } |
| 876 | |
| 877 | bool flush() |
| 878 | { |
no outgoing calls
no test coverage detected