MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Read

Method Read

src/saveload/saveload.cpp:2708–2727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2706 }
2707
2708 size_t Read(uint8_t *buf, size_t size) override
2709 {
2710 this->lzma.next_out = buf;
2711 this->lzma.avail_out = size;
2712
2713 do {
2714 /* read more bytes from the file? */
2715 if (this->lzma.avail_in == 0) {
2716 this->lzma.next_in = this->fread_buf;
2717 this->lzma.avail_in = this->chain->Read(this->fread_buf, sizeof(this->fread_buf));
2718 }
2719
2720 /* inflate the data */
2721 lzma_ret r = lzma_code(&this->lzma, LZMA_RUN);
2722 if (r == LZMA_STREAM_END) break;
2723 if (r != LZMA_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "liblzma returned error code");
2724 } while (this->lzma.avail_out != 0);
2725
2726 return size - this->lzma.avail_out;
2727 }
2728};
2729
2730/** Filter using LZMA compression. */

Callers

nothing calls this directly

Calls 2

SlErrorFunction · 0.85
ReadMethod · 0.45

Tested by

no test coverage detected