From 30984deafc05d7c6f88db736336fe73d23a08e19 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 10 Nov 2004 21:02:58 +0000 Subject: [PATCH] new set of fixes for problems due to huge files support: drop wxFileSize_t, use wxFileOffset only, make wxInvalidOffset an int (main part of the patch 1063498) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/file.h | 22 +++++++++--------- include/wx/filefn.h | 16 +++---------- include/wx/stream.h | 2 +- samples/console/console.cpp | 6 ++--- src/common/file.cpp | 44 +++++++++++++++++++++-------------- src/common/filefn.cpp | 2 +- src/common/gifdecod.cpp | 2 +- src/common/imagbmp.cpp | 2 +- src/common/image.cpp | 2 +- src/common/imagiff.cpp | 4 ++-- src/common/imagtiff.cpp | 4 ++-- src/common/intl.cpp | 22 +++++++++++------- src/common/stream.cpp | 20 ++++++++-------- src/common/textfile.cpp | 6 ++--- src/common/wfstream.cpp | 14 +++++------ src/common/xpmdecod.cpp | 2 +- src/html/chm.cpp | 10 ++++---- src/msw/gdiimage.cpp | 2 +- src/msw/urlmsw.cpp | 4 ++-- src/unix/snglinst.cpp | 4 ++-- tests/streams/bstream.h | 8 +++---- utils/HelpGen/src/HelpGen.cpp | 7 ++++-- 22 files changed, 106 insertions(+), 99 deletions(-) diff --git a/include/wx/file.h b/include/wx/file.h index b767d0a4a0..6a46ec7fe4 100644 --- a/include/wx/file.h +++ b/include/wx/file.h @@ -95,28 +95,28 @@ public: // read/write (unbuffered) // returns number of bytes read or ofsInvalid on error - wxFileSize_t Read(void *pBuf, wxFileSize_t nCount); + size_t Read(void *pBuf, size_t nCount); // returns the number of bytes written - wxFileSize_t Write(const void *pBuf, wxFileSize_t nCount); + size_t Write(const void *pBuf, size_t nCount); // returns true on success bool Write(const wxString& s, wxMBConv& conv = wxConvUTF8) { const wxWX2MBbuf buf = s.mb_str(conv); - wxFileSize_t size = strlen(buf); + size_t size = strlen(buf); return Write((const char *) buf, size) == size; } // flush data not yet written bool Flush(); - // file pointer operations (return ofsInvalid on failure) - // move ptr ofs bytes related to start/current off_t/end of file - wxFileSize_t Seek(wxFileOffset ofs, wxSeekMode mode = wxFromStart); + // file pointer operations (return wxInvalidOffset on failure) + // move ptr ofs bytes related to start/current offset/end of file + wxFileOffset Seek(wxFileOffset ofs, wxSeekMode mode = wxFromStart); // move ptr to ofs bytes before the end - wxFileSize_t SeekEnd(wxFileOffset ofs = 0) { return Seek(ofs, wxFromEnd); } - // get current off_t - wxFileSize_t Tell() const; + wxFileOffset SeekEnd(wxFileOffset ofs = 0) { return Seek(ofs, wxFromEnd); } + // get current offset + wxFileOffset Tell() const; // get current file length - wxFileSize_t Length() const; + wxFileOffset Length() const; // simple accessors // is file opened? @@ -164,7 +164,7 @@ public: bool IsOpened() const { return m_file.IsOpened(); } // I/O (both functions return true on success, false on failure) - bool Write(const void *p, wxFileSize_t n) { return m_file.Write(p, n) == n; } + bool Write(const void *p, size_t n) { return m_file.Write(p, n) == n; } bool Write(const wxString& str, wxMBConv& conv = wxConvUTF8) { return m_file.Write(str, conv); } diff --git a/include/wx/filefn.h b/include/wx/filefn.h index b977aaf14a..d112029e3b 100644 --- a/include/wx/filefn.h +++ b/include/wx/filefn.h @@ -131,7 +131,6 @@ enum wxSeekMode // Implemented in filefnwce.cpp #if defined( __WXWINCE__) typedef __int64 wxFileOffset; - typedef unsigned __int64 wxFileSize_t; #define wxFileOffsetFmtSpec _("I64") int wxOpen(const wxChar *filename, int oflag, int WXUNUSED(pmode)); int wxAccess(const wxChar *name, int WXUNUSED(how)); @@ -198,11 +197,9 @@ enum wxSeekMode #if wxHAS_HUGE_FILES typedef wxLongLong_t wxFileOffset; - typedef unsigned wxLongLong_t wxFileSize_t; #define wxFileOffsetFmtSpec wxLongLongFmtSpec #else typedef off_t wxFileOffset; - typedef unsigned long wxFileSize_t; #endif #define wxClose _close @@ -218,12 +215,7 @@ enum wxSeekMode _write(fd, (const char *)buf, nCount) #endif #else - #if defined(__WATCOMC__) - inline wxFileSize_t wxRead( int handle, void *buffer, wxFileSize_t len ) - { return ::read( handle, buffer, (unsigned int)len ); } - inline wxFileSize_t wxWrite( int handle, const void *buffer, wxFileSize_t len ) - { return ::write( handle, buffer, (unsigned int)len ); } - #elif defined(__DMC__) + #if defined(__DMC__) || defined(__WATCOMC__) #define wxRead ::read #define wxWrite ::write #else @@ -332,10 +324,8 @@ enum wxSeekMode #define wxFileOffsetFmtSpec wxLongLongFmtSpec wxCOMPILE_TIME_ASSERT( sizeof(off_t) == sizeof(wxLongLong_t), BadFileSizeType ); - typedef unsigned wxLongLong_t wxFileSize_t; #else #define wxFileOffsetFmtSpec _T("") - typedef unsigned long wxFileSize_t; #endif // functions #define wxClose close @@ -373,9 +363,9 @@ enum wxSeekMode // VisualAge C++ V4.0 cannot have any external linkage const decs // in headers included by more than one primary source // -extern const wxFileSize_t wxInvalidOffset; +extern const int wxInvalidOffset; #else -const wxFileSize_t wxInvalidOffset = (wxFileSize_t)-1; +const int wxInvalidOffset = -1; #endif // ---------------------------------------------------------------------------- diff --git a/include/wx/stream.h b/include/wx/stream.h index 3824fd1026..9f627b9be6 100644 --- a/include/wx/stream.h +++ b/include/wx/stream.h @@ -23,7 +23,7 @@ #include #include "wx/object.h" #include "wx/string.h" -#include "wx/filefn.h" // for off_t, wxInvalidOffset and wxSeekMode +#include "wx/filefn.h" // for wxFileOffset, wxInvalidOffset and wxSeekMode class WXDLLIMPEXP_BASE wxStreamBase; class WXDLLIMPEXP_BASE wxInputStream; diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 1bedd459bc..0a961b1676 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -575,12 +575,12 @@ static void TestFileRead() wxPuts(_T("File dump:\n----------")); - static const off_t len = 1024; + static const size_t len = 1024; wxChar buf[len]; for ( ;; ) { - off_t nRead = file.Read(buf, len); - if ( nRead == wxInvalidOffset ) + size_t nRead = file.Read(buf, len); + if ( nRead == (size_t)wxInvalidOffset ) { wxPrintf(_T("Failed to read the file.")); break; diff --git a/src/common/file.cpp b/src/common/file.cpp index 07ad817056..55d70d03db 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -144,6 +144,15 @@ #include "wx/msw/private.h" #endif +#if !defined __UNIX__ && !defined __DJGPP__ + #ifdef __WXWINCE__ + typedef int ssize_t; + #else + typedef ptrdiff_t ssize_t; + #endif +#endif +wxCOMPILE_TIME_ASSERT(sizeof(ssize_t) == sizeof(size_t), ssize_t_wrong_size); + // ============================================================================ // implementation of wxFile // ============================================================================ @@ -298,35 +307,36 @@ bool wxFile::Close() // ---------------------------------------------------------------------------- // read -wxFileSize_t wxFile::Read(void *pBuf, wxFileSize_t nCount) +size_t wxFile::Read(void *pBuf, size_t nCount) { wxCHECK( (pBuf != NULL) && IsOpened(), 0 ); - wxFileSize_t iRc = wxRead(m_fd, pBuf, nCount); + ssize_t iRc = wxRead(m_fd, pBuf, nCount); - if ( iRc == wxInvalidOffset ) + if ( iRc == -1 ) { wxLogSysError(_("can't read from file descriptor %d"), m_fd); + return (size_t)wxInvalidOffset; } return iRc; } // write -wxFileSize_t wxFile::Write(const void *pBuf, wxFileSize_t nCount) +size_t wxFile::Write(const void *pBuf, size_t nCount) { wxCHECK( (pBuf != NULL) && IsOpened(), 0 ); - wxFileSize_t iRc = wxWrite(m_fd, pBuf, nCount); + ssize_t iRc = wxWrite(m_fd, pBuf, nCount); - if ( iRc == wxInvalidOffset ) + if ( iRc == -1 ) { wxLogSysError(_("can't write to file descriptor %d"), m_fd); m_error = true; iRc = 0; } - return (wxFileSize_t)iRc; + return iRc; } // flush @@ -352,7 +362,7 @@ bool wxFile::Flush() // ---------------------------------------------------------------------------- // seek -wxFileSize_t wxFile::Seek(wxFileOffset ofs, wxSeekMode mode) +wxFileOffset wxFile::Seek(wxFileOffset ofs, wxSeekMode mode) { wxASSERT( IsOpened() ); @@ -374,12 +384,12 @@ wxFileSize_t wxFile::Seek(wxFileOffset ofs, wxSeekMode mode) break; } - if (ofs == (wxFileOffset) wxInvalidOffset) + if (ofs == wxInvalidOffset) { wxLogSysError(_("can't seek on file descriptor %d, large files support is not enabled."), m_fd); return wxInvalidOffset; } - wxFileSize_t iRc = wxSeek(m_fd, ofs, origin); + wxFileOffset iRc = wxSeek(m_fd, ofs, origin); if ( iRc == wxInvalidOffset ) { wxLogSysError(_("can't seek on file descriptor %d"), m_fd); @@ -389,11 +399,11 @@ wxFileSize_t wxFile::Seek(wxFileOffset ofs, wxSeekMode mode) } // get current file offset -wxFileSize_t wxFile::Tell() const +wxFileOffset wxFile::Tell() const { wxASSERT( IsOpened() ); - wxFileSize_t iRc = wxTell(m_fd); + wxFileOffset iRc = wxTell(m_fd); if ( iRc == wxInvalidOffset ) { wxLogSysError(_("can't get seek position on file descriptor %d"), m_fd); @@ -403,14 +413,14 @@ wxFileSize_t wxFile::Tell() const } // get current file length -wxFileSize_t wxFile::Length() const +wxFileOffset wxFile::Length() const { wxASSERT( IsOpened() ); - wxFileSize_t iRc = Tell(); + wxFileOffset iRc = Tell(); if ( iRc != wxInvalidOffset ) { // have to use const_cast :-( - wxFileSize_t iLen = ((wxFile *)this)->SeekEnd(); + wxFileOffset iLen = ((wxFile *)this)->SeekEnd(); if ( iLen != wxInvalidOffset ) { // restore old position if ( ((wxFile *)this)->Seek(iRc) == wxInvalidOffset ) { @@ -435,11 +445,11 @@ bool wxFile::Eof() const { wxASSERT( IsOpened() ); - wxFileSize_t iRc; + wxFileOffset iRc; #if defined(__DOS__) || defined(__UNIX__) || defined(__GNUWIN32__) || defined( __MWERKS__ ) || defined(__SALFORDC__) // @@ this doesn't work, of course, on unseekable file descriptors - wxFileSize_t ofsCur = Tell(), + wxFileOffset ofsCur = Tell(), ofsMax = Length(); if ( ofsCur == wxInvalidOffset || ofsMax == wxInvalidOffset ) iRc = wxInvalidOffset; diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index f0ab27e53c..1ed5377151 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -104,7 +104,7 @@ static wxChar wxFileFunctionsBuffer[4*_MAXPATHLEN]; // VisualAge C++ V4.0 cannot have any external linkage const decs // in headers included by more than one primary source // -const wxFileSize_t wxInvalidOffset = (wxFileSize_t)-1; +const int wxInvalidOffset = -1; #endif // ---------------------------------------------------------------------------- diff --git a/src/common/gifdecod.cpp b/src/common/gifdecod.cpp index 732557ca3b..c9cfe9b16e 100644 --- a/src/common/gifdecod.cpp +++ b/src/common/gifdecod.cpp @@ -621,7 +621,7 @@ bool wxGIFDecoder::CanRead() if ( !m_f->Read(buf, WXSIZEOF(buf)) ) return false; - m_f->SeekI(-(off_t)WXSIZEOF(buf), wxFromCurrent); + m_f->SeekI(-(wxFileOffset)WXSIZEOF(buf), wxFromCurrent); return memcmp(buf, "GIF", WXSIZEOF(buf)) == 0; } diff --git a/src/common/imagbmp.cpp b/src/common/imagbmp.cpp index c699ae596f..09b1a9387f 100644 --- a/src/common/imagbmp.cpp +++ b/src/common/imagbmp.cpp @@ -844,7 +844,7 @@ bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream, wxInt32 dbuf[4]; wxInt8 bbuf[4]; - wxFileSize_t offset = 0; // keep gcc quiet + wxFileOffset offset = 0; // keep gcc quiet if ( IsBmp ) { // read the header off the .BMP format file diff --git a/src/common/image.cpp b/src/common/image.cpp index 784a016b94..afd54ca636 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -1481,7 +1481,7 @@ bool wxImageHandler::CanRead( const wxString& name ) bool wxImageHandler::CallDoCanRead(wxInputStream& stream) { - wxFileSize_t posOld = stream.TellI(); + wxFileOffset posOld = stream.TellI(); if ( posOld == wxInvalidOffset ) { // can't test unseekable stream diff --git a/src/common/imagiff.cpp b/src/common/imagiff.cpp index 5a6dc5cced..b6db906cdb 100644 --- a/src/common/imagiff.cpp +++ b/src/common/imagiff.cpp @@ -239,7 +239,7 @@ bool wxIFFDecoder::CanRead() if ( !m_f->Read(buf, WXSIZEOF(buf)) ) return false; - m_f->SeekI(-(off_t)WXSIZEOF(buf), wxFromCurrent); + m_f->SeekI(-(wxFileOffset)WXSIZEOF(buf), wxFromCurrent); return (memcmp(buf, "FORM", 4) == 0) && (memcmp(buf+8, "ILBM", 4) == 0); } @@ -339,7 +339,7 @@ int wxIFFDecoder::ReadIFF() } // compute file length - off_t currentPos = m_f->TellI(); + wxFileOffset currentPos = m_f->TellI(); m_f->SeekI(0, wxFromEnd); long filesize = m_f->TellI(); m_f->SeekI(currentPos, wxFromStart); diff --git a/src/common/imagtiff.cpp b/src/common/imagtiff.cpp index ef9589c911..3cd681f757 100644 --- a/src/common/imagtiff.cpp +++ b/src/common/imagtiff.cpp @@ -89,7 +89,7 @@ _tiffSeekIProc(thandle_t handle, toff_t off, int whence) default: mode = wxFromCurrent; break; } - return (toff_t)stream->SeekI( (off_t)off, mode ); + return (toff_t)stream->SeekI( (wxFileOffset)off, mode ); } toff_t TIFFLINKAGEMODE @@ -105,7 +105,7 @@ _tiffSeekOProc(thandle_t handle, toff_t off, int whence) default: mode = wxFromCurrent; break; } - return (toff_t)stream->SeekO( (off_t)off, mode ); + return (toff_t)stream->SeekO( (wxFileOffset)off, mode ); } int TIFFLINKAGEMODE diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 2350c1a41e..7dbd7b0cb3 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -1037,6 +1037,8 @@ static wxString GetFullSearchPath(const wxChar *lang) << wxPATH_SEP; } + // TODO: use wxStandardPaths instead of all this mess!! + // LC_PATH is a standard env var containing the search path for the .mo // files #ifndef __WXWINCE__ @@ -1056,14 +1058,16 @@ static wxString GetFullSearchPath(const wxChar *lang) // then take the current directory // FIXME it should be the directory of the executable -#ifdef __WXMAC__ - wxChar cwd[512] ; - wxGetWorkingDirectory( cwd , sizeof( cwd ) ) ; - searchPath << GetAllMsgCatalogSubdirs(cwd, lang); +#if defined(__WXMAC__) + searchPath << GetAllMsgCatalogSubdirs(wxGetCwd(), lang); // generic search paths could be somewhere in the system folder preferences -#else // !Mac +#elif defined(__WXMSW__) + // look in the directory of the executable + wxString path; + wxSplitPath(wxGetFullModuleName(), &path, NULL, NULL); + searchPath << GetAllMsgCatalogSubdirs(path, lang); +#else // !Mac, !MSW searchPath << GetAllMsgCatalogSubdirs(wxT("."), lang); - #endif // platform return searchPath; @@ -1120,19 +1124,19 @@ bool wxMsgCatalogFile::Load(const wxChar *szDirPrefix, const wxChar *szName0, return false; // get the file size (assume it is less than 4Gb...) - wxFileSize_t nSize = fileMsg.Length(); + wxFileOffset nSize = fileMsg.Length(); if ( nSize == wxInvalidOffset ) return false; // read the whole file in memory m_pData = new size_t8[nSize]; - if ( fileMsg.Read(m_pData, nSize) != nSize ) { + if ( fileMsg.Read(m_pData, nSize) != nSize + (size_t)0 ) { wxDELETEA(m_pData); return false; } // examine header - bool bValid = nSize > sizeof(wxMsgCatalogHeader); + bool bValid = nSize + (size_t)0 > sizeof(wxMsgCatalogHeader); wxMsgCatalogHeader *pHeader = (wxMsgCatalogHeader *)m_pData; if ( bValid ) { diff --git a/src/common/stream.cpp b/src/common/stream.cpp index 3230417f2c..f1d432eb69 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -576,10 +576,10 @@ wxFileOffset wxStreamBuffer::Seek(wxFileOffset pos, wxSeekMode mode) default: wxFAIL_MSG( _T("invalid seek mode") ); - return (wxFileOffset) wxInvalidOffset; + return wxInvalidOffset; } if (diff < 0 || diff > last_access) - return (wxFileOffset) wxInvalidOffset; + return wxInvalidOffset; SetIntPosition(diff); return diff; } @@ -616,19 +616,19 @@ wxFileOffset wxStreamBuffer::Seek(wxFileOffset pos, wxSeekMode mode) return ret_off; } - return (wxFileOffset) wxInvalidOffset; + return wxInvalidOffset; } wxFileOffset wxStreamBuffer::Tell() const { - wxFileSize_t pos; + wxFileOffset pos; // ask the stream for position if we have a real one if ( m_stream ) { pos = m_stream->OnSysTell(); if ( pos == wxInvalidOffset ) - return (wxFileOffset) wxInvalidOffset; + return wxInvalidOffset; } else // no associated stream { @@ -659,12 +659,12 @@ wxStreamBase::~wxStreamBase() wxFileOffset wxStreamBase::OnSysSeek(wxFileOffset WXUNUSED(seek), wxSeekMode WXUNUSED(mode)) { - return (wxFileOffset) wxInvalidOffset; + return wxInvalidOffset; } wxFileOffset wxStreamBase::OnSysTell() const { - return (wxFileOffset) wxInvalidOffset; + return wxInvalidOffset; } // ---------------------------------------------------------------------------- @@ -889,7 +889,7 @@ wxFileOffset wxInputStream::SeekI(wxFileOffset pos, wxSeekMode mode) wxFileOffset wxInputStream::TellI() const { - wxFileSize_t pos = OnSysTell(); + wxFileOffset pos = OnSysTell(); if (pos != wxInvalidOffset) pos -= (m_wbacksize - m_wbackcur); @@ -990,7 +990,7 @@ wxFileOffset wxCountingOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode default: wxFAIL_MSG( _T("invalid seek mode") ); - return (wxFileOffset) wxInvalidOffset; + return wxInvalidOffset; } if (m_currentPos > m_lastcount) @@ -1122,7 +1122,7 @@ wxFileOffset wxBufferedInputStream::SeekI(wxFileOffset pos, wxSeekMode mode) wxFileOffset wxBufferedInputStream::TellI() const { - wxFileSize_t pos = m_i_streambuf->Tell(); + wxFileOffset pos = m_i_streambuf->Tell(); if (pos != wxInvalidOffset) pos -= (m_wbacksize - m_wbackcur); diff --git a/src/common/textfile.cpp b/src/common/textfile.cpp index 604bb54c4c..25503be862 100644 --- a/src/common/textfile.cpp +++ b/src/common/textfile.cpp @@ -97,7 +97,7 @@ bool wxTextFile::OnRead(wxMBConv& conv) char *strBuf, *strPtr, *strEnd; char ch, chLast = '\0'; char buf[1024]; - wxFileSize_t nRead; + size_t nRead; strPtr = strBuf = new char[1024]; strEnd = strBuf + 1024; @@ -105,14 +105,14 @@ bool wxTextFile::OnRead(wxMBConv& conv) do { nRead = m_file.Read(buf, WXSIZEOF(buf)); - if ( nRead == wxInvalidOffset ) + if ( nRead == (size_t)wxInvalidOffset ) { // read error (error message already given in wxFile::Read) delete[] strBuf; return false; } - for (wxFileSize_t n = 0; n < nRead; n++) + for (size_t n = 0; n < nRead; n++) { ch = buf[n]; switch ( ch ) diff --git a/src/common/wfstream.cpp b/src/common/wfstream.cpp index 970f92c296..a1b94af437 100644 --- a/src/common/wfstream.cpp +++ b/src/common/wfstream.cpp @@ -69,17 +69,17 @@ size_t wxFileInputStream::GetSize() const size_t wxFileInputStream::OnSysRead(void *buffer, size_t size) { - wxFileSize_t ret = m_file->Read(buffer, size); + size_t ret = m_file->Read(buffer, size); // NB: we can't use a switch here because HP-UX CC doesn't allow - // switching over long long (which off_t is in 64bit mode) + // switching over long long (which size_t is in 64bit mode) if ( !ret ) { // nothing read, so nothing more to read m_lasterror = wxSTREAM_EOF; } - else if ( ret == wxInvalidOffset ) + else if ( ret == (size_t)wxInvalidOffset ) { m_lasterror = wxSTREAM_READ_ERROR; ret = 0; @@ -234,11 +234,11 @@ size_t wxFFileInputStream::GetSize() const size_t wxFFileInputStream::OnSysRead(void *buffer, size_t size) { - wxFileSize_t ret = m_file->Read(buffer, size); + size_t ret = m_file->Read(buffer, size); if (m_file->Eof()) m_lasterror = wxSTREAM_EOF; - if (ret == wxInvalidOffset) + if (ret == (size_t)wxInvalidOffset) { m_lasterror = wxSTREAM_READ_ERROR; ret = 0; @@ -252,7 +252,7 @@ wxFileOffset wxFFileInputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode) #ifdef __VMS #pragma message disable intsignchange #endif - return ( m_file->Seek(pos, mode) ? m_file->Tell() : wxInvalidOffset ); + return ( m_file->Seek(pos, mode) ? (wxFileOffset)m_file->Tell() : wxInvalidOffset ); #ifdef __VMS #pragma message enable intsignchange #endif @@ -331,7 +331,7 @@ wxFileOffset wxFFileOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode) #ifdef __VMS #pragma message disable intsignchange #endif - return ( m_file->Seek(pos, mode) ? m_file->Tell() : wxInvalidOffset ); + return ( m_file->Seek(pos, mode) ? (wxFileOffset)m_file->Tell() : wxInvalidOffset ); #ifdef __VMS #pragma message enable intsignchange #endif diff --git a/src/common/xpmdecod.cpp b/src/common/xpmdecod.cpp index 69a91e7c60..89cdad65ee 100644 --- a/src/common/xpmdecod.cpp +++ b/src/common/xpmdecod.cpp @@ -127,7 +127,7 @@ bool wxXPMDecoder::CanRead(wxInputStream& stream) if ( !stream.Read(buf, WXSIZEOF(buf)) ) return false; - stream.SeekI(-(off_t)WXSIZEOF(buf), wxFromCurrent); + stream.SeekI(-(wxFileOffset)WXSIZEOF(buf), wxFromCurrent); return memcmp(buf, "/* XPM */", WXSIZEOF(buf)) == 0; } diff --git a/src/html/chm.cpp b/src/html/chm.cpp index 627b039f33..b7dc1ee4f5 100644 --- a/src/html/chm.cpp +++ b/src/html/chm.cpp @@ -377,13 +377,13 @@ protected: /// See wxInputStream virtual size_t OnSysRead(void *buffer, size_t bufsize); /// See wxInputStream - virtual off_t OnSysSeek(off_t seek, wxSeekMode mode); + virtual wxFileOffset OnSysSeek(wxFileOffset seek, wxSeekMode mode); /// See wxInputStream - virtual off_t OnSysTell() const { return m_pos; } + virtual wxFileOffset OnSysTell() const { return m_pos; } private: size_t m_size; - off_t m_pos; + wxFileOffset m_pos; bool m_simulateHHP; char * m_content; @@ -501,7 +501,7 @@ size_t wxChmInputStream::OnSysRead(void *buffer, size_t bufsize) -off_t wxChmInputStream::OnSysSeek(off_t seek, wxSeekMode mode) +wxFileOffset wxChmInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode) { wxString mode_str = wxEmptyString; @@ -512,7 +512,7 @@ off_t wxChmInputStream::OnSysSeek(off_t seek, wxSeekMode mode) } m_lasterror = wxSTREAM_NO_ERROR; - off_t nextpos; + wxFileOffset nextpos; switch ( mode ) { diff --git a/src/msw/gdiimage.cpp b/src/msw/gdiimage.cpp index cba8189116..f6dc5a9096 100644 --- a/src/msw/gdiimage.cpp +++ b/src/msw/gdiimage.cpp @@ -648,7 +648,7 @@ HBITMAP wxLoadBMP(const wxString& filename) pBmpInfo->bmiHeader.biClrUsed : 1 << pBmpInfo->bmiHeader.biBitCount; if (nColors < 1 || file.Read(pBmpInfo->bmiColors, nColors * sizeof(RGBQUAD)) - == (off_t)(nColors * sizeof(RGBQUAD))) { + == nColors * sizeof(RGBQUAD)) { // So how big the bitmap surface is. int nBitsSize = BmpFileHdr.bfSize - BmpFileHdr.bfOffBits; diff --git a/src/msw/urlmsw.cpp b/src/msw/urlmsw.cpp index a5c5fd3b37..5b16115615 100644 --- a/src/msw/urlmsw.cpp +++ b/src/msw/urlmsw.cpp @@ -122,9 +122,9 @@ public: void Attach(HINTERNET hFile); - off_t SeekI( off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode) ) + wxFileOffset SeekI( wxFileOffset WXUNUSED(pos), wxSeekMode WXUNUSED(mode) ) { return -1; } - off_t TellI() const + wxFileOffset TellI() const { return -1; } protected: diff --git a/src/unix/snglinst.cpp b/src/unix/snglinst.cpp index d581d39f83..af5e2063a5 100644 --- a/src/unix/snglinst.cpp +++ b/src/unix/snglinst.cpp @@ -277,8 +277,8 @@ bool wxSingleInstanceCheckerImpl::Create(const wxString& name) } char buf[256]; - wxFileSize_t count = file.Read(buf, WXSIZEOF(buf)); - if ( count == wxInvalidOffset ) + size_t count = file.Read(buf, WXSIZEOF(buf)); + if ( count == (size_t)wxInvalidOffset ) { wxLogError(_("Failed to read PID from lock file.")); } diff --git a/tests/streams/bstream.h b/tests/streams/bstream.h index 3505fc33aa..4d15aa503f 100644 --- a/tests/streams/bstream.h +++ b/tests/streams/bstream.h @@ -208,7 +208,7 @@ protected: CPPUNIT_ASSERT(stream_in.TellI() == 1); if (!m_bSimpleTellITest) { - off_t pos = stream_in.SeekI(5, wxFromStart); + wxFileOffset pos = stream_in.SeekI(5, wxFromStart); CPPUNIT_ASSERT(stream_in.TellI() == pos); (void)stream_in.GetC(); CPPUNIT_ASSERT(stream_in.TellI() == 6); @@ -269,8 +269,8 @@ protected: TStreamOut &stream_out = CreateOutStream(); char *buf = "Some text"; - off_t i; - off_t len = (off_t) strlen(buf); + int i; + int len = strlen(buf); for (i = 0; i < len; i++) stream_out.PutC(buf[i]); @@ -285,7 +285,7 @@ protected: // Do the buffer version. char *buf = "Some text"; - off_t len = (off_t) strlen(buf); + int len = strlen(buf); (void)stream_out.Write(buf, len); CPPUNIT_ASSERT(stream_out.TellO() == len); diff --git a/utils/HelpGen/src/HelpGen.cpp b/utils/HelpGen/src/HelpGen.cpp index d2dc393cd2..95155b320b 100644 --- a/utils/HelpGen/src/HelpGen.cpp +++ b/utils/HelpGen/src/HelpGen.cpp @@ -1417,7 +1417,7 @@ bool DocManager::ParseTeXFile(const wxString& filename) char *buf = new char[len + 1]; buf[len] = '\0'; - if ( (wxFileOffset)file.Read(buf, len) == wxInvalidOffset ) { + if ( file.Read(buf, len) == (size_t)wxInvalidOffset ) { delete [] buf; return false; @@ -1988,7 +1988,7 @@ bool IgnoreNamesHandler::AddNamesFromFile(const wxString& filename) char *buf = new char[len + 1]; buf[len] = '\0'; - if ( (wxFileOffset)file.Read(buf, len) == wxInvalidOffset ) { + if ( file.Read(buf, len) == (size_t)wxInvalidOffset ) { delete [] buf; return false; @@ -2186,6 +2186,9 @@ static const wxString GetVersionString() /* $Log$ + Revision 1.32 2004/11/10 21:02:58 VZ + new set of fixes for problems due to huge files support: drop wxFileSize_t, use wxFileOffset only, make wxInvalidOffset an int (main part of the patch 1063498) + Revision 1.31 2004/10/05 15:38:29 ABX Warning fixes found under hardest mode of OpenWatcom. Seems clean in Borland, MinGW and DMC. -- 2.45.2