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
This commit is contained in:
Michael Wetherell 2005-03-24 23:48:06 +00:00
parent 67631cee52
commit 8019e60483

View File

@ -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 */
}