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

Method WriteLoop

src/saveload/saveload.cpp:2757–2775  ·  view source on GitHub ↗

* Helper loop for writing the data. * @param p The bytes to write. * @param len Amount of bytes to write. * @param action Action for lzma_code. */

Source from the content-addressed store, hash-verified

2755 * @param action Action for lzma_code.
2756 */
2757 void WriteLoop(uint8_t *p, size_t len, lzma_action action)
2758 {
2759 size_t n;
2760 this->lzma.next_in = p;
2761 this->lzma.avail_in = len;
2762 do {
2763 this->lzma.next_out = this->fwrite_buf;
2764 this->lzma.avail_out = sizeof(this->fwrite_buf);
2765
2766 lzma_ret r = lzma_code(&this->lzma, action);
2767
2768 /* bytes were emitted? */
2769 if ((n = sizeof(this->fwrite_buf) - this->lzma.avail_out) != 0) {
2770 this->chain->Write(this->fwrite_buf, n);
2771 }
2772 if (r == LZMA_STREAM_END) break;
2773 if (r != LZMA_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "liblzma returned error code");
2774 } while (this->lzma.avail_in || !this->lzma.avail_out);
2775 }
2776
2777 void Write(uint8_t *buf, size_t size) override
2778 {

Callers 2

WriteMethod · 0.95
FinishMethod · 0.95

Calls 2

SlErrorFunction · 0.85
WriteMethod · 0.45

Tested by

no test coverage detected