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
This commit is contained in:
@@ -95,28 +95,28 @@ public:
|
|||||||
|
|
||||||
// read/write (unbuffered)
|
// read/write (unbuffered)
|
||||||
// returns number of bytes read or ofsInvalid on error
|
// 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
|
// 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
|
// returns true on success
|
||||||
bool Write(const wxString& s, wxMBConv& conv = wxConvUTF8)
|
bool Write(const wxString& s, wxMBConv& conv = wxConvUTF8)
|
||||||
{
|
{
|
||||||
const wxWX2MBbuf buf = s.mb_str(conv);
|
const wxWX2MBbuf buf = s.mb_str(conv);
|
||||||
wxFileSize_t size = strlen(buf);
|
size_t size = strlen(buf);
|
||||||
return Write((const char *) buf, size) == size;
|
return Write((const char *) buf, size) == size;
|
||||||
}
|
}
|
||||||
// flush data not yet written
|
// flush data not yet written
|
||||||
bool Flush();
|
bool Flush();
|
||||||
|
|
||||||
// file pointer operations (return ofsInvalid on failure)
|
// file pointer operations (return wxInvalidOffset on failure)
|
||||||
// move ptr ofs bytes related to start/current off_t/end of file
|
// move ptr ofs bytes related to start/current offset/end of file
|
||||||
wxFileSize_t Seek(wxFileOffset ofs, wxSeekMode mode = wxFromStart);
|
wxFileOffset Seek(wxFileOffset ofs, wxSeekMode mode = wxFromStart);
|
||||||
// move ptr to ofs bytes before the end
|
// move ptr to ofs bytes before the end
|
||||||
wxFileSize_t SeekEnd(wxFileOffset ofs = 0) { return Seek(ofs, wxFromEnd); }
|
wxFileOffset SeekEnd(wxFileOffset ofs = 0) { return Seek(ofs, wxFromEnd); }
|
||||||
// get current off_t
|
// get current offset
|
||||||
wxFileSize_t Tell() const;
|
wxFileOffset Tell() const;
|
||||||
// get current file length
|
// get current file length
|
||||||
wxFileSize_t Length() const;
|
wxFileOffset Length() const;
|
||||||
|
|
||||||
// simple accessors
|
// simple accessors
|
||||||
// is file opened?
|
// is file opened?
|
||||||
@@ -164,7 +164,7 @@ public:
|
|||||||
bool IsOpened() const { return m_file.IsOpened(); }
|
bool IsOpened() const { return m_file.IsOpened(); }
|
||||||
|
|
||||||
// I/O (both functions return true on success, false on failure)
|
// 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)
|
bool Write(const wxString& str, wxMBConv& conv = wxConvUTF8)
|
||||||
{ return m_file.Write(str, conv); }
|
{ return m_file.Write(str, conv); }
|
||||||
|
|
||||||
|
@@ -131,7 +131,6 @@ enum wxSeekMode
|
|||||||
// Implemented in filefnwce.cpp
|
// Implemented in filefnwce.cpp
|
||||||
#if defined( __WXWINCE__)
|
#if defined( __WXWINCE__)
|
||||||
typedef __int64 wxFileOffset;
|
typedef __int64 wxFileOffset;
|
||||||
typedef unsigned __int64 wxFileSize_t;
|
|
||||||
#define wxFileOffsetFmtSpec _("I64")
|
#define wxFileOffsetFmtSpec _("I64")
|
||||||
int wxOpen(const wxChar *filename, int oflag, int WXUNUSED(pmode));
|
int wxOpen(const wxChar *filename, int oflag, int WXUNUSED(pmode));
|
||||||
int wxAccess(const wxChar *name, int WXUNUSED(how));
|
int wxAccess(const wxChar *name, int WXUNUSED(how));
|
||||||
@@ -198,11 +197,9 @@ enum wxSeekMode
|
|||||||
|
|
||||||
#if wxHAS_HUGE_FILES
|
#if wxHAS_HUGE_FILES
|
||||||
typedef wxLongLong_t wxFileOffset;
|
typedef wxLongLong_t wxFileOffset;
|
||||||
typedef unsigned wxLongLong_t wxFileSize_t;
|
|
||||||
#define wxFileOffsetFmtSpec wxLongLongFmtSpec
|
#define wxFileOffsetFmtSpec wxLongLongFmtSpec
|
||||||
#else
|
#else
|
||||||
typedef off_t wxFileOffset;
|
typedef off_t wxFileOffset;
|
||||||
typedef unsigned long wxFileSize_t;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define wxClose _close
|
#define wxClose _close
|
||||||
@@ -218,12 +215,7 @@ enum wxSeekMode
|
|||||||
_write(fd, (const char *)buf, nCount)
|
_write(fd, (const char *)buf, nCount)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if defined(__WATCOMC__)
|
#if defined(__DMC__) || 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__)
|
|
||||||
#define wxRead ::read
|
#define wxRead ::read
|
||||||
#define wxWrite ::write
|
#define wxWrite ::write
|
||||||
#else
|
#else
|
||||||
@@ -332,10 +324,8 @@ enum wxSeekMode
|
|||||||
#define wxFileOffsetFmtSpec wxLongLongFmtSpec
|
#define wxFileOffsetFmtSpec wxLongLongFmtSpec
|
||||||
wxCOMPILE_TIME_ASSERT( sizeof(off_t) == sizeof(wxLongLong_t),
|
wxCOMPILE_TIME_ASSERT( sizeof(off_t) == sizeof(wxLongLong_t),
|
||||||
BadFileSizeType );
|
BadFileSizeType );
|
||||||
typedef unsigned wxLongLong_t wxFileSize_t;
|
|
||||||
#else
|
#else
|
||||||
#define wxFileOffsetFmtSpec _T("")
|
#define wxFileOffsetFmtSpec _T("")
|
||||||
typedef unsigned long wxFileSize_t;
|
|
||||||
#endif
|
#endif
|
||||||
// functions
|
// functions
|
||||||
#define wxClose close
|
#define wxClose close
|
||||||
@@ -373,9 +363,9 @@ enum wxSeekMode
|
|||||||
// VisualAge C++ V4.0 cannot have any external linkage const decs
|
// VisualAge C++ V4.0 cannot have any external linkage const decs
|
||||||
// in headers included by more than one primary source
|
// in headers included by more than one primary source
|
||||||
//
|
//
|
||||||
extern const wxFileSize_t wxInvalidOffset;
|
extern const int wxInvalidOffset;
|
||||||
#else
|
#else
|
||||||
const wxFileSize_t wxInvalidOffset = (wxFileSize_t)-1;
|
const int wxInvalidOffset = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "wx/object.h"
|
#include "wx/object.h"
|
||||||
#include "wx/string.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 wxStreamBase;
|
||||||
class WXDLLIMPEXP_BASE wxInputStream;
|
class WXDLLIMPEXP_BASE wxInputStream;
|
||||||
|
@@ -575,12 +575,12 @@ static void TestFileRead()
|
|||||||
|
|
||||||
wxPuts(_T("File dump:\n----------"));
|
wxPuts(_T("File dump:\n----------"));
|
||||||
|
|
||||||
static const off_t len = 1024;
|
static const size_t len = 1024;
|
||||||
wxChar buf[len];
|
wxChar buf[len];
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
off_t nRead = file.Read(buf, len);
|
size_t nRead = file.Read(buf, len);
|
||||||
if ( nRead == wxInvalidOffset )
|
if ( nRead == (size_t)wxInvalidOffset )
|
||||||
{
|
{
|
||||||
wxPrintf(_T("Failed to read the file."));
|
wxPrintf(_T("Failed to read the file."));
|
||||||
break;
|
break;
|
||||||
|
@@ -144,6 +144,15 @@
|
|||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
#endif
|
#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
|
// implementation of wxFile
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -298,35 +307,36 @@ bool wxFile::Close()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// read
|
// read
|
||||||
wxFileSize_t wxFile::Read(void *pBuf, wxFileSize_t nCount)
|
size_t wxFile::Read(void *pBuf, size_t nCount)
|
||||||
{
|
{
|
||||||
wxCHECK( (pBuf != NULL) && IsOpened(), 0 );
|
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);
|
wxLogSysError(_("can't read from file descriptor %d"), m_fd);
|
||||||
|
return (size_t)wxInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iRc;
|
return iRc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write
|
// 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 );
|
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);
|
wxLogSysError(_("can't write to file descriptor %d"), m_fd);
|
||||||
m_error = true;
|
m_error = true;
|
||||||
iRc = 0;
|
iRc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (wxFileSize_t)iRc;
|
return iRc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// flush
|
// flush
|
||||||
@@ -352,7 +362,7 @@ bool wxFile::Flush()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// seek
|
// seek
|
||||||
wxFileSize_t wxFile::Seek(wxFileOffset ofs, wxSeekMode mode)
|
wxFileOffset wxFile::Seek(wxFileOffset ofs, wxSeekMode mode)
|
||||||
{
|
{
|
||||||
wxASSERT( IsOpened() );
|
wxASSERT( IsOpened() );
|
||||||
|
|
||||||
@@ -374,12 +384,12 @@ wxFileSize_t wxFile::Seek(wxFileOffset ofs, wxSeekMode mode)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ofs == (wxFileOffset) wxInvalidOffset)
|
if (ofs == wxInvalidOffset)
|
||||||
{
|
{
|
||||||
wxLogSysError(_("can't seek on file descriptor %d, large files support is not enabled."), m_fd);
|
wxLogSysError(_("can't seek on file descriptor %d, large files support is not enabled."), m_fd);
|
||||||
return wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
}
|
}
|
||||||
wxFileSize_t iRc = wxSeek(m_fd, ofs, origin);
|
wxFileOffset iRc = wxSeek(m_fd, ofs, origin);
|
||||||
if ( iRc == wxInvalidOffset )
|
if ( iRc == wxInvalidOffset )
|
||||||
{
|
{
|
||||||
wxLogSysError(_("can't seek on file descriptor %d"), m_fd);
|
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
|
// get current file offset
|
||||||
wxFileSize_t wxFile::Tell() const
|
wxFileOffset wxFile::Tell() const
|
||||||
{
|
{
|
||||||
wxASSERT( IsOpened() );
|
wxASSERT( IsOpened() );
|
||||||
|
|
||||||
wxFileSize_t iRc = wxTell(m_fd);
|
wxFileOffset iRc = wxTell(m_fd);
|
||||||
if ( iRc == wxInvalidOffset )
|
if ( iRc == wxInvalidOffset )
|
||||||
{
|
{
|
||||||
wxLogSysError(_("can't get seek position on file descriptor %d"), m_fd);
|
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
|
// get current file length
|
||||||
wxFileSize_t wxFile::Length() const
|
wxFileOffset wxFile::Length() const
|
||||||
{
|
{
|
||||||
wxASSERT( IsOpened() );
|
wxASSERT( IsOpened() );
|
||||||
|
|
||||||
wxFileSize_t iRc = Tell();
|
wxFileOffset iRc = Tell();
|
||||||
if ( iRc != wxInvalidOffset ) {
|
if ( iRc != wxInvalidOffset ) {
|
||||||
// have to use const_cast :-(
|
// have to use const_cast :-(
|
||||||
wxFileSize_t iLen = ((wxFile *)this)->SeekEnd();
|
wxFileOffset iLen = ((wxFile *)this)->SeekEnd();
|
||||||
if ( iLen != wxInvalidOffset ) {
|
if ( iLen != wxInvalidOffset ) {
|
||||||
// restore old position
|
// restore old position
|
||||||
if ( ((wxFile *)this)->Seek(iRc) == wxInvalidOffset ) {
|
if ( ((wxFile *)this)->Seek(iRc) == wxInvalidOffset ) {
|
||||||
@@ -435,11 +445,11 @@ bool wxFile::Eof() const
|
|||||||
{
|
{
|
||||||
wxASSERT( IsOpened() );
|
wxASSERT( IsOpened() );
|
||||||
|
|
||||||
wxFileSize_t iRc;
|
wxFileOffset iRc;
|
||||||
|
|
||||||
#if defined(__DOS__) || defined(__UNIX__) || defined(__GNUWIN32__) || defined( __MWERKS__ ) || defined(__SALFORDC__)
|
#if defined(__DOS__) || defined(__UNIX__) || defined(__GNUWIN32__) || defined( __MWERKS__ ) || defined(__SALFORDC__)
|
||||||
// @@ this doesn't work, of course, on unseekable file descriptors
|
// @@ this doesn't work, of course, on unseekable file descriptors
|
||||||
wxFileSize_t ofsCur = Tell(),
|
wxFileOffset ofsCur = Tell(),
|
||||||
ofsMax = Length();
|
ofsMax = Length();
|
||||||
if ( ofsCur == wxInvalidOffset || ofsMax == wxInvalidOffset )
|
if ( ofsCur == wxInvalidOffset || ofsMax == wxInvalidOffset )
|
||||||
iRc = wxInvalidOffset;
|
iRc = wxInvalidOffset;
|
||||||
|
@@ -104,7 +104,7 @@ static wxChar wxFileFunctionsBuffer[4*_MAXPATHLEN];
|
|||||||
// VisualAge C++ V4.0 cannot have any external linkage const decs
|
// VisualAge C++ V4.0 cannot have any external linkage const decs
|
||||||
// in headers included by more than one primary source
|
// in headers included by more than one primary source
|
||||||
//
|
//
|
||||||
const wxFileSize_t wxInvalidOffset = (wxFileSize_t)-1;
|
const int wxInvalidOffset = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -621,7 +621,7 @@ bool wxGIFDecoder::CanRead()
|
|||||||
if ( !m_f->Read(buf, WXSIZEOF(buf)) )
|
if ( !m_f->Read(buf, WXSIZEOF(buf)) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_f->SeekI(-(off_t)WXSIZEOF(buf), wxFromCurrent);
|
m_f->SeekI(-(wxFileOffset)WXSIZEOF(buf), wxFromCurrent);
|
||||||
|
|
||||||
return memcmp(buf, "GIF", WXSIZEOF(buf)) == 0;
|
return memcmp(buf, "GIF", WXSIZEOF(buf)) == 0;
|
||||||
}
|
}
|
||||||
|
@@ -844,7 +844,7 @@ bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream,
|
|||||||
wxInt32 dbuf[4];
|
wxInt32 dbuf[4];
|
||||||
wxInt8 bbuf[4];
|
wxInt8 bbuf[4];
|
||||||
|
|
||||||
wxFileSize_t offset = 0; // keep gcc quiet
|
wxFileOffset offset = 0; // keep gcc quiet
|
||||||
if ( IsBmp )
|
if ( IsBmp )
|
||||||
{
|
{
|
||||||
// read the header off the .BMP format file
|
// read the header off the .BMP format file
|
||||||
|
@@ -1481,7 +1481,7 @@ bool wxImageHandler::CanRead( const wxString& name )
|
|||||||
|
|
||||||
bool wxImageHandler::CallDoCanRead(wxInputStream& stream)
|
bool wxImageHandler::CallDoCanRead(wxInputStream& stream)
|
||||||
{
|
{
|
||||||
wxFileSize_t posOld = stream.TellI();
|
wxFileOffset posOld = stream.TellI();
|
||||||
if ( posOld == wxInvalidOffset )
|
if ( posOld == wxInvalidOffset )
|
||||||
{
|
{
|
||||||
// can't test unseekable stream
|
// can't test unseekable stream
|
||||||
|
@@ -239,7 +239,7 @@ bool wxIFFDecoder::CanRead()
|
|||||||
if ( !m_f->Read(buf, WXSIZEOF(buf)) )
|
if ( !m_f->Read(buf, WXSIZEOF(buf)) )
|
||||||
return false;
|
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);
|
return (memcmp(buf, "FORM", 4) == 0) && (memcmp(buf+8, "ILBM", 4) == 0);
|
||||||
}
|
}
|
||||||
@@ -339,7 +339,7 @@ int wxIFFDecoder::ReadIFF()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// compute file length
|
// compute file length
|
||||||
off_t currentPos = m_f->TellI();
|
wxFileOffset currentPos = m_f->TellI();
|
||||||
m_f->SeekI(0, wxFromEnd);
|
m_f->SeekI(0, wxFromEnd);
|
||||||
long filesize = m_f->TellI();
|
long filesize = m_f->TellI();
|
||||||
m_f->SeekI(currentPos, wxFromStart);
|
m_f->SeekI(currentPos, wxFromStart);
|
||||||
|
@@ -89,7 +89,7 @@ _tiffSeekIProc(thandle_t handle, toff_t off, int whence)
|
|||||||
default: mode = wxFromCurrent; break;
|
default: mode = wxFromCurrent; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (toff_t)stream->SeekI( (off_t)off, mode );
|
return (toff_t)stream->SeekI( (wxFileOffset)off, mode );
|
||||||
}
|
}
|
||||||
|
|
||||||
toff_t TIFFLINKAGEMODE
|
toff_t TIFFLINKAGEMODE
|
||||||
@@ -105,7 +105,7 @@ _tiffSeekOProc(thandle_t handle, toff_t off, int whence)
|
|||||||
default: mode = wxFromCurrent; break;
|
default: mode = wxFromCurrent; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (toff_t)stream->SeekO( (off_t)off, mode );
|
return (toff_t)stream->SeekO( (wxFileOffset)off, mode );
|
||||||
}
|
}
|
||||||
|
|
||||||
int TIFFLINKAGEMODE
|
int TIFFLINKAGEMODE
|
||||||
|
@@ -1037,6 +1037,8 @@ static wxString GetFullSearchPath(const wxChar *lang)
|
|||||||
<< wxPATH_SEP;
|
<< wxPATH_SEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: use wxStandardPaths instead of all this mess!!
|
||||||
|
|
||||||
// LC_PATH is a standard env var containing the search path for the .mo
|
// LC_PATH is a standard env var containing the search path for the .mo
|
||||||
// files
|
// files
|
||||||
#ifndef __WXWINCE__
|
#ifndef __WXWINCE__
|
||||||
@@ -1056,14 +1058,16 @@ static wxString GetFullSearchPath(const wxChar *lang)
|
|||||||
|
|
||||||
// then take the current directory
|
// then take the current directory
|
||||||
// FIXME it should be the directory of the executable
|
// FIXME it should be the directory of the executable
|
||||||
#ifdef __WXMAC__
|
#if defined(__WXMAC__)
|
||||||
wxChar cwd[512] ;
|
searchPath << GetAllMsgCatalogSubdirs(wxGetCwd(), lang);
|
||||||
wxGetWorkingDirectory( cwd , sizeof( cwd ) ) ;
|
|
||||||
searchPath << GetAllMsgCatalogSubdirs(cwd, lang);
|
|
||||||
// generic search paths could be somewhere in the system folder preferences
|
// 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);
|
searchPath << GetAllMsgCatalogSubdirs(wxT("."), lang);
|
||||||
|
|
||||||
#endif // platform
|
#endif // platform
|
||||||
|
|
||||||
return searchPath;
|
return searchPath;
|
||||||
@@ -1120,19 +1124,19 @@ bool wxMsgCatalogFile::Load(const wxChar *szDirPrefix, const wxChar *szName0,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// get the file size (assume it is less than 4Gb...)
|
// get the file size (assume it is less than 4Gb...)
|
||||||
wxFileSize_t nSize = fileMsg.Length();
|
wxFileOffset nSize = fileMsg.Length();
|
||||||
if ( nSize == wxInvalidOffset )
|
if ( nSize == wxInvalidOffset )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// read the whole file in memory
|
// read the whole file in memory
|
||||||
m_pData = new size_t8[nSize];
|
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);
|
wxDELETEA(m_pData);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// examine header
|
// examine header
|
||||||
bool bValid = nSize > sizeof(wxMsgCatalogHeader);
|
bool bValid = nSize + (size_t)0 > sizeof(wxMsgCatalogHeader);
|
||||||
|
|
||||||
wxMsgCatalogHeader *pHeader = (wxMsgCatalogHeader *)m_pData;
|
wxMsgCatalogHeader *pHeader = (wxMsgCatalogHeader *)m_pData;
|
||||||
if ( bValid ) {
|
if ( bValid ) {
|
||||||
|
@@ -576,10 +576,10 @@ wxFileOffset wxStreamBuffer::Seek(wxFileOffset pos, wxSeekMode mode)
|
|||||||
default:
|
default:
|
||||||
wxFAIL_MSG( _T("invalid seek mode") );
|
wxFAIL_MSG( _T("invalid seek mode") );
|
||||||
|
|
||||||
return (wxFileOffset) wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
}
|
}
|
||||||
if (diff < 0 || diff > last_access)
|
if (diff < 0 || diff > last_access)
|
||||||
return (wxFileOffset) wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
SetIntPosition(diff);
|
SetIntPosition(diff);
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
@@ -616,19 +616,19 @@ wxFileOffset wxStreamBuffer::Seek(wxFileOffset pos, wxSeekMode mode)
|
|||||||
return ret_off;
|
return ret_off;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (wxFileOffset) wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileOffset wxStreamBuffer::Tell() const
|
wxFileOffset wxStreamBuffer::Tell() const
|
||||||
{
|
{
|
||||||
wxFileSize_t pos;
|
wxFileOffset pos;
|
||||||
|
|
||||||
// ask the stream for position if we have a real one
|
// ask the stream for position if we have a real one
|
||||||
if ( m_stream )
|
if ( m_stream )
|
||||||
{
|
{
|
||||||
pos = m_stream->OnSysTell();
|
pos = m_stream->OnSysTell();
|
||||||
if ( pos == wxInvalidOffset )
|
if ( pos == wxInvalidOffset )
|
||||||
return (wxFileOffset) wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
}
|
}
|
||||||
else // no associated stream
|
else // no associated stream
|
||||||
{
|
{
|
||||||
@@ -659,12 +659,12 @@ wxStreamBase::~wxStreamBase()
|
|||||||
|
|
||||||
wxFileOffset wxStreamBase::OnSysSeek(wxFileOffset WXUNUSED(seek), wxSeekMode WXUNUSED(mode))
|
wxFileOffset wxStreamBase::OnSysSeek(wxFileOffset WXUNUSED(seek), wxSeekMode WXUNUSED(mode))
|
||||||
{
|
{
|
||||||
return (wxFileOffset) wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileOffset wxStreamBase::OnSysTell() const
|
wxFileOffset wxStreamBase::OnSysTell() const
|
||||||
{
|
{
|
||||||
return (wxFileOffset) wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -889,7 +889,7 @@ wxFileOffset wxInputStream::SeekI(wxFileOffset pos, wxSeekMode mode)
|
|||||||
|
|
||||||
wxFileOffset wxInputStream::TellI() const
|
wxFileOffset wxInputStream::TellI() const
|
||||||
{
|
{
|
||||||
wxFileSize_t pos = OnSysTell();
|
wxFileOffset pos = OnSysTell();
|
||||||
|
|
||||||
if (pos != wxInvalidOffset)
|
if (pos != wxInvalidOffset)
|
||||||
pos -= (m_wbacksize - m_wbackcur);
|
pos -= (m_wbacksize - m_wbackcur);
|
||||||
@@ -990,7 +990,7 @@ wxFileOffset wxCountingOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( _T("invalid seek mode") );
|
wxFAIL_MSG( _T("invalid seek mode") );
|
||||||
return (wxFileOffset) wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_currentPos > m_lastcount)
|
if (m_currentPos > m_lastcount)
|
||||||
@@ -1122,7 +1122,7 @@ wxFileOffset wxBufferedInputStream::SeekI(wxFileOffset pos, wxSeekMode mode)
|
|||||||
|
|
||||||
wxFileOffset wxBufferedInputStream::TellI() const
|
wxFileOffset wxBufferedInputStream::TellI() const
|
||||||
{
|
{
|
||||||
wxFileSize_t pos = m_i_streambuf->Tell();
|
wxFileOffset pos = m_i_streambuf->Tell();
|
||||||
|
|
||||||
if (pos != wxInvalidOffset)
|
if (pos != wxInvalidOffset)
|
||||||
pos -= (m_wbacksize - m_wbackcur);
|
pos -= (m_wbacksize - m_wbackcur);
|
||||||
|
@@ -97,7 +97,7 @@ bool wxTextFile::OnRead(wxMBConv& conv)
|
|||||||
char *strBuf, *strPtr, *strEnd;
|
char *strBuf, *strPtr, *strEnd;
|
||||||
char ch, chLast = '\0';
|
char ch, chLast = '\0';
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
wxFileSize_t nRead;
|
size_t nRead;
|
||||||
|
|
||||||
strPtr = strBuf = new char[1024];
|
strPtr = strBuf = new char[1024];
|
||||||
strEnd = strBuf + 1024;
|
strEnd = strBuf + 1024;
|
||||||
@@ -105,14 +105,14 @@ bool wxTextFile::OnRead(wxMBConv& conv)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
nRead = m_file.Read(buf, WXSIZEOF(buf));
|
nRead = m_file.Read(buf, WXSIZEOF(buf));
|
||||||
if ( nRead == wxInvalidOffset )
|
if ( nRead == (size_t)wxInvalidOffset )
|
||||||
{
|
{
|
||||||
// read error (error message already given in wxFile::Read)
|
// read error (error message already given in wxFile::Read)
|
||||||
delete[] strBuf;
|
delete[] strBuf;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (wxFileSize_t n = 0; n < nRead; n++)
|
for (size_t n = 0; n < nRead; n++)
|
||||||
{
|
{
|
||||||
ch = buf[n];
|
ch = buf[n];
|
||||||
switch ( ch )
|
switch ( ch )
|
||||||
|
@@ -69,17 +69,17 @@ size_t wxFileInputStream::GetSize() const
|
|||||||
|
|
||||||
size_t wxFileInputStream::OnSysRead(void *buffer, size_t size)
|
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
|
// 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 )
|
if ( !ret )
|
||||||
{
|
{
|
||||||
// nothing read, so nothing more to read
|
// nothing read, so nothing more to read
|
||||||
m_lasterror = wxSTREAM_EOF;
|
m_lasterror = wxSTREAM_EOF;
|
||||||
}
|
}
|
||||||
else if ( ret == wxInvalidOffset )
|
else if ( ret == (size_t)wxInvalidOffset )
|
||||||
{
|
{
|
||||||
m_lasterror = wxSTREAM_READ_ERROR;
|
m_lasterror = wxSTREAM_READ_ERROR;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@@ -234,11 +234,11 @@ size_t wxFFileInputStream::GetSize() const
|
|||||||
|
|
||||||
size_t wxFFileInputStream::OnSysRead(void *buffer, size_t size)
|
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())
|
if (m_file->Eof())
|
||||||
m_lasterror = wxSTREAM_EOF;
|
m_lasterror = wxSTREAM_EOF;
|
||||||
if (ret == wxInvalidOffset)
|
if (ret == (size_t)wxInvalidOffset)
|
||||||
{
|
{
|
||||||
m_lasterror = wxSTREAM_READ_ERROR;
|
m_lasterror = wxSTREAM_READ_ERROR;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@@ -252,7 +252,7 @@ wxFileOffset wxFFileInputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
|
|||||||
#ifdef __VMS
|
#ifdef __VMS
|
||||||
#pragma message disable intsignchange
|
#pragma message disable intsignchange
|
||||||
#endif
|
#endif
|
||||||
return ( m_file->Seek(pos, mode) ? m_file->Tell() : wxInvalidOffset );
|
return ( m_file->Seek(pos, mode) ? (wxFileOffset)m_file->Tell() : wxInvalidOffset );
|
||||||
#ifdef __VMS
|
#ifdef __VMS
|
||||||
#pragma message enable intsignchange
|
#pragma message enable intsignchange
|
||||||
#endif
|
#endif
|
||||||
@@ -331,7 +331,7 @@ wxFileOffset wxFFileOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode)
|
|||||||
#ifdef __VMS
|
#ifdef __VMS
|
||||||
#pragma message disable intsignchange
|
#pragma message disable intsignchange
|
||||||
#endif
|
#endif
|
||||||
return ( m_file->Seek(pos, mode) ? m_file->Tell() : wxInvalidOffset );
|
return ( m_file->Seek(pos, mode) ? (wxFileOffset)m_file->Tell() : wxInvalidOffset );
|
||||||
#ifdef __VMS
|
#ifdef __VMS
|
||||||
#pragma message enable intsignchange
|
#pragma message enable intsignchange
|
||||||
#endif
|
#endif
|
||||||
|
@@ -127,7 +127,7 @@ bool wxXPMDecoder::CanRead(wxInputStream& stream)
|
|||||||
if ( !stream.Read(buf, WXSIZEOF(buf)) )
|
if ( !stream.Read(buf, WXSIZEOF(buf)) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
stream.SeekI(-(off_t)WXSIZEOF(buf), wxFromCurrent);
|
stream.SeekI(-(wxFileOffset)WXSIZEOF(buf), wxFromCurrent);
|
||||||
|
|
||||||
return memcmp(buf, "/* XPM */", WXSIZEOF(buf)) == 0;
|
return memcmp(buf, "/* XPM */", WXSIZEOF(buf)) == 0;
|
||||||
}
|
}
|
||||||
|
@@ -377,13 +377,13 @@ protected:
|
|||||||
/// See wxInputStream
|
/// See wxInputStream
|
||||||
virtual size_t OnSysRead(void *buffer, size_t bufsize);
|
virtual size_t OnSysRead(void *buffer, size_t bufsize);
|
||||||
/// See wxInputStream
|
/// See wxInputStream
|
||||||
virtual off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
virtual wxFileOffset OnSysSeek(wxFileOffset seek, wxSeekMode mode);
|
||||||
/// See wxInputStream
|
/// See wxInputStream
|
||||||
virtual off_t OnSysTell() const { return m_pos; }
|
virtual wxFileOffset OnSysTell() const { return m_pos; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t m_size;
|
size_t m_size;
|
||||||
off_t m_pos;
|
wxFileOffset m_pos;
|
||||||
bool m_simulateHHP;
|
bool m_simulateHHP;
|
||||||
|
|
||||||
char * m_content;
|
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;
|
wxString mode_str = wxEmptyString;
|
||||||
|
|
||||||
@@ -512,7 +512,7 @@ off_t wxChmInputStream::OnSysSeek(off_t seek, wxSeekMode mode)
|
|||||||
}
|
}
|
||||||
m_lasterror = wxSTREAM_NO_ERROR;
|
m_lasterror = wxSTREAM_NO_ERROR;
|
||||||
|
|
||||||
off_t nextpos;
|
wxFileOffset nextpos;
|
||||||
|
|
||||||
switch ( mode )
|
switch ( mode )
|
||||||
{
|
{
|
||||||
|
@@ -648,7 +648,7 @@ HBITMAP wxLoadBMP(const wxString& filename)
|
|||||||
pBmpInfo->bmiHeader.biClrUsed : 1 << pBmpInfo->bmiHeader.biBitCount;
|
pBmpInfo->bmiHeader.biClrUsed : 1 << pBmpInfo->bmiHeader.biBitCount;
|
||||||
if (nColors < 1
|
if (nColors < 1
|
||||||
|| file.Read(pBmpInfo->bmiColors, nColors * sizeof(RGBQUAD))
|
|| file.Read(pBmpInfo->bmiColors, nColors * sizeof(RGBQUAD))
|
||||||
== (off_t)(nColors * sizeof(RGBQUAD))) {
|
== nColors * sizeof(RGBQUAD)) {
|
||||||
|
|
||||||
// So how big the bitmap surface is.
|
// So how big the bitmap surface is.
|
||||||
int nBitsSize = BmpFileHdr.bfSize - BmpFileHdr.bfOffBits;
|
int nBitsSize = BmpFileHdr.bfSize - BmpFileHdr.bfOffBits;
|
||||||
|
@@ -122,9 +122,9 @@ public:
|
|||||||
|
|
||||||
void Attach(HINTERNET hFile);
|
void Attach(HINTERNET hFile);
|
||||||
|
|
||||||
off_t SeekI( off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode) )
|
wxFileOffset SeekI( wxFileOffset WXUNUSED(pos), wxSeekMode WXUNUSED(mode) )
|
||||||
{ return -1; }
|
{ return -1; }
|
||||||
off_t TellI() const
|
wxFileOffset TellI() const
|
||||||
{ return -1; }
|
{ return -1; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -277,8 +277,8 @@ bool wxSingleInstanceCheckerImpl::Create(const wxString& name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
wxFileSize_t count = file.Read(buf, WXSIZEOF(buf));
|
size_t count = file.Read(buf, WXSIZEOF(buf));
|
||||||
if ( count == wxInvalidOffset )
|
if ( count == (size_t)wxInvalidOffset )
|
||||||
{
|
{
|
||||||
wxLogError(_("Failed to read PID from lock file."));
|
wxLogError(_("Failed to read PID from lock file."));
|
||||||
}
|
}
|
||||||
|
@@ -208,7 +208,7 @@ protected:
|
|||||||
CPPUNIT_ASSERT(stream_in.TellI() == 1);
|
CPPUNIT_ASSERT(stream_in.TellI() == 1);
|
||||||
if (!m_bSimpleTellITest)
|
if (!m_bSimpleTellITest)
|
||||||
{
|
{
|
||||||
off_t pos = stream_in.SeekI(5, wxFromStart);
|
wxFileOffset pos = stream_in.SeekI(5, wxFromStart);
|
||||||
CPPUNIT_ASSERT(stream_in.TellI() == pos);
|
CPPUNIT_ASSERT(stream_in.TellI() == pos);
|
||||||
(void)stream_in.GetC();
|
(void)stream_in.GetC();
|
||||||
CPPUNIT_ASSERT(stream_in.TellI() == 6);
|
CPPUNIT_ASSERT(stream_in.TellI() == 6);
|
||||||
@@ -269,8 +269,8 @@ protected:
|
|||||||
TStreamOut &stream_out = CreateOutStream();
|
TStreamOut &stream_out = CreateOutStream();
|
||||||
|
|
||||||
char *buf = "Some text";
|
char *buf = "Some text";
|
||||||
off_t i;
|
int i;
|
||||||
off_t len = (off_t) strlen(buf);
|
int len = strlen(buf);
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
stream_out.PutC(buf[i]);
|
stream_out.PutC(buf[i]);
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ protected:
|
|||||||
|
|
||||||
// Do the buffer version.
|
// Do the buffer version.
|
||||||
char *buf = "Some text";
|
char *buf = "Some text";
|
||||||
off_t len = (off_t) strlen(buf);
|
int len = strlen(buf);
|
||||||
(void)stream_out.Write(buf, len);
|
(void)stream_out.Write(buf, len);
|
||||||
CPPUNIT_ASSERT(stream_out.TellO() == len);
|
CPPUNIT_ASSERT(stream_out.TellO() == len);
|
||||||
|
|
||||||
|
@@ -1417,7 +1417,7 @@ bool DocManager::ParseTeXFile(const wxString& filename)
|
|||||||
char *buf = new char[len + 1];
|
char *buf = new char[len + 1];
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
if ( (wxFileOffset)file.Read(buf, len) == wxInvalidOffset ) {
|
if ( file.Read(buf, len) == (size_t)wxInvalidOffset ) {
|
||||||
delete [] buf;
|
delete [] buf;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -1988,7 +1988,7 @@ bool IgnoreNamesHandler::AddNamesFromFile(const wxString& filename)
|
|||||||
char *buf = new char[len + 1];
|
char *buf = new char[len + 1];
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
if ( (wxFileOffset)file.Read(buf, len) == wxInvalidOffset ) {
|
if ( file.Read(buf, len) == (size_t)wxInvalidOffset ) {
|
||||||
delete [] buf;
|
delete [] buf;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -2186,6 +2186,9 @@ static const wxString GetVersionString()
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
$Log$
|
$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
|
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.
|
Warning fixes found under hardest mode of OpenWatcom. Seems clean in Borland, MinGW and DMC.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user