From 723306c417b3b0f8e6a3904906d6c5612cace432 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 4 Jun 2023 14:36:25 +0200 Subject: libio: Move istream_t precache logic into backend implementation The end goal is to remove direct buffer access from the istream_t interfaces and make that opaque. For the tar implementation, this already safes us needless buffer copying, as we essentially allow the user to read-through from the underlying stream. Signed-off-by: David Oberhollenzer --- lib/tar/src/iterator.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/tar/src') diff --git a/lib/tar/src/iterator.c b/lib/tar/src/iterator.c index 0940905..532eb8c 100644 --- a/lib/tar/src/iterator.c +++ b/lib/tar/src/iterator.c @@ -104,6 +104,12 @@ static int strm_precache(istream_t *strm) tar_istream_t *tar = (tar_istream_t *)strm; sqfs_u64 diff; + strm->buffer_used -= strm->buffer_offset; + strm->buffer_offset = 0; + + if (strm->eof) + return 0; + tar->parent->offset += tar->parent->last_chunk; if (!tar->parent->last_sparse) { -- cgit v1.2.3