From 8019e6048307a401f547933d4419df4234a84c0b Mon Sep 17 00:00:00 2001 From: Michael Wetherell Date: Thu, 24 Mar 2005 23:48:06 +0000 Subject: [PATCH] Fix wxZipInputStream::SeekI (returns wxInvalidOffset before first read) patch 1169934 by Artur Kornacki git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33040 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/zipstrm.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/zipstrm.cpp b/src/common/zipstrm.cpp index 1c10609715..eacd2b1d9c 100644 --- a/src/common/zipstrm.cpp +++ b/src/common/zipstrm.cpp @@ -1746,7 +1746,12 @@ size_t wxZipInputStream::OnSysRead(void *buffer, size_t size) // wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode) { - if (!m_ffile || AtHeader()) + if (!m_ffile) + return wxInvalidOffset; + if (!IsOpened()) + if ((AtHeader() && !DoOpen()) || !OpenDecompressor()) + m_lasterror = wxSTREAM_READ_ERROR; + if (!IsOk()) return wxInvalidOffset; // NB: since ZIP files don't natively support seeking, we have to @@ -1761,7 +1766,7 @@ wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode) { case wxFromCurrent : nextpos = seek + pos; break; case wxFromStart : nextpos = seek; break; - case wxFromEnd : nextpos = GetLength() - 1 + seek; break; + case wxFromEnd : nextpos = GetLength() + seek; break; default : nextpos = pos; break; /* just to fool compiler, never happens */ } -- 2.45.2