X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/12811c1c3bf188b29188ede4e4320db9ff74b691..acd32ffcdb319f162633c20e0202db3f8542998a:/src/common/fileback.cpp diff --git a/src/common/fileback.cpp b/src/common/fileback.cpp index a0cbc707d8..6e4253c0f7 100644 --- a/src/common/fileback.cpp +++ b/src/common/fileback.cpp @@ -14,9 +14,9 @@ #pragma hdrstop #endif -#if wxUSE_BACKINGFILE +#if wxUSE_FILESYSTEM -#include "wx/fileback.h" +#include "wx/private/fileback.h" #ifndef WX_PRECOMP #include "wx/utils.h" @@ -83,7 +83,7 @@ wxBackingFileImpl::wxBackingFileImpl(wxInputStream *stream, wxFileOffset len = m_stream->GetLength(); if (len >= 0 && len + size_t(1) < m_bufsize) - m_bufsize = len + 1; + m_bufsize = size_t(len + 1); if (m_bufsize) m_buf = new char[m_bufsize]; @@ -271,6 +271,29 @@ wxBackedInputStream::wxBackedInputStream(const wxBackingFile& backer) { } +wxFileOffset wxBackedInputStream::GetLength() const +{ + return m_backer.m_impl->GetLength(); +} + +wxFileOffset wxBackedInputStream::FindLength() const +{ + wxFileOffset len = GetLength(); + + if (len == wxInvalidOffset && IsOk()) { + // read a byte at 7ff...ffe + wxFileOffset pos = 1; + pos <<= sizeof(pos) * 8 - 1; + pos = ~pos - 1; + char ch; + size_t size = 1; + m_backer.m_impl->ReadAt(pos, &ch, &size); + len = GetLength(); + } + + return len; +} + size_t wxBackedInputStream::OnSysRead(void *buffer, size_t size) { if (!IsOk()) @@ -281,11 +304,6 @@ size_t wxBackedInputStream::OnSysRead(void *buffer, size_t size) return size; } -wxFileOffset wxBackedInputStream::GetLength() const -{ - return m_backer.m_impl->GetLength(); -} - wxFileOffset wxBackedInputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode) { switch (mode) { @@ -317,4 +335,4 @@ wxFileOffset wxBackedInputStream::OnSysTell() const return m_pos; } -#endif // wxUSE_BACKINGFILE +#endif // wxUSE_FILESYSTEM