| 2579 | } |
| 2580 | |
| 2581 | size_t Read(uint8_t *buf, size_t size) override |
| 2582 | { |
| 2583 | this->z.next_out = buf; |
| 2584 | this->z.avail_out = (uint)size; |
| 2585 | |
| 2586 | do { |
| 2587 | /* read more bytes from the file? */ |
| 2588 | if (this->z.avail_in == 0) { |
| 2589 | this->z.next_in = this->fread_buf; |
| 2590 | this->z.avail_in = (uint)this->chain->Read(this->fread_buf, sizeof(this->fread_buf)); |
| 2591 | } |
| 2592 | |
| 2593 | /* inflate the data */ |
| 2594 | int r = inflate(&this->z, 0); |
| 2595 | if (r == Z_STREAM_END) break; |
| 2596 | |
| 2597 | if (r != Z_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "inflate() failed"); |
| 2598 | } while (this->z.avail_out != 0); |
| 2599 | |
| 2600 | return size - this->z.avail_out; |
| 2601 | } |
| 2602 | }; |
| 2603 | |
| 2604 | /** Filter using Zlib compression. */ |