From f3c7e011959f3be924582cde99dcf326d7702094 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Dec 2023 16:58:12 +0100 Subject: [PATCH] fixed BufferingReader --- src/common/filesystem/source/files.cpp | 2 +- src/common/filesystem/source/files_decompress.cpp | 5 +++-- src/common/filesystem/source/files_internal.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common/filesystem/source/files.cpp b/src/common/filesystem/source/files.cpp index 87eee970d0..9f0d24fc2b 100644 --- a/src/common/filesystem/source/files.cpp +++ b/src/common/filesystem/source/files.cpp @@ -334,7 +334,7 @@ int BufferingReader::FillBuffer(ptrdiff_t newpos) // we have read the entire file, so delete our data provider. baseReader.reset(); } - return read == newpos - bufferpos ? 0 : -1; + return newpos == bufferpos ? 0 : -1; } ptrdiff_t BufferingReader::Seek(ptrdiff_t offset, int origin) diff --git a/src/common/filesystem/source/files_decompress.cpp b/src/common/filesystem/source/files_decompress.cpp index 0bbb80c522..8bf681357d 100644 --- a/src/common/filesystem/source/files_decompress.cpp +++ b/src/common/filesystem/source/files_decompress.cpp @@ -181,7 +181,7 @@ public: inflateEnd (&Stream); } - ptrdiff_t Read (void *buffer, ptrdiff_t len) override + ptrdiff_t Read (void *buffer, ptrdiff_t olen) override { int err = 0; @@ -190,6 +190,7 @@ public: DecompressionError("File not open"); return 0; } + auto len = olen; if (len == 0) return 0; while (len > 0) @@ -222,7 +223,7 @@ public: return 0; } - return len - Stream.avail_out; + return olen - Stream.avail_out; } void FillBuffer () diff --git a/src/common/filesystem/source/files_internal.h b/src/common/filesystem/source/files_internal.h index 38a28e6e33..f8563eebcb 100644 --- a/src/common/filesystem/source/files_internal.h +++ b/src/common/filesystem/source/files_internal.h @@ -42,6 +42,7 @@ public: { Length = base->Length; buf.resize(Length); + bufptr = (const char*)buf.data(); } ptrdiff_t Seek(ptrdiff_t offset, int origin) override;