Backport stdio large file support for VC++ and mingw.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@63300 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Michael Wetherell
2010-01-28 21:36:09 +00:00
parent 7749dce6bb
commit 1132633751
4 changed files with 38 additions and 19 deletions

View File

@@ -166,7 +166,9 @@ enum wxFileKind
defined(__BORLANDC__) \ defined(__BORLANDC__) \
) )
// temporary defines just used immediately below
#undef wxHAS_HUGE_FILES #undef wxHAS_HUGE_FILES
#undef wxHAS_HUGE_STDIO_FILES
// detect compilers which have support for huge files // detect compilers which have support for huge files
#if defined(__VISUALC__) #if defined(__VISUALC__)
@@ -177,6 +179,17 @@ enum wxFileKind
#define wxHAS_HUGE_FILES 1 #define wxHAS_HUGE_FILES 1
#endif #endif
// detect compilers which have support for huge stdio files
#if defined __VISUALC__ && __VISUALC__ >= 1400
#define wxHAS_HUGE_STDIO_FILES
#define wxFseek _fseeki64
#define wxFtell _ftelli64
#elif wxCHECK_MINGW32_VERSION(3, 5) // mingw-runtime version (not gcc)
#define wxHAS_HUGE_STDIO_FILES
#define wxFseek fseeko64
#define wxFtell ftello64
#endif
// other Windows compilers (DMC, Watcom, Metrowerks and Borland) don't have // other Windows compilers (DMC, Watcom, Metrowerks and Borland) don't have
// huge file support (or at least not all functions needed for it by wx) // huge file support (or at least not all functions needed for it by wx)
// currently // currently
@@ -381,16 +394,19 @@ enum wxFileKind
#endif // wxHAS_UNDERSCORES_IN_POSIX_IDENTS #endif // wxHAS_UNDERSCORES_IN_POSIX_IDENTS
#ifdef wxHAS_HUGE_FILES #ifdef wxHAS_HUGE_FILES
// wxFile is present and supports large files. Currently wxFFile // wxFile is present and supports large files.
// doesn't have large file support with any Windows compiler (even
// Win64 ones).
#if wxUSE_FILE #if wxUSE_FILE
#define wxHAS_LARGE_FILES #define wxHAS_LARGE_FILES
#endif #endif
// wxFFile is present and supports large files
#if wxUSE_FFILE && defined wxHAS_HUGE_STDIO_FILES
#define wxHAS_LARGE_FFILES
#endif
#endif #endif
// it's a private define, undefine it so that nobody gets tempted to use it // private defines, undefine so that nobody gets tempted to use
#undef wxHAS_HUGE_FILES #undef wxHAS_HUGE_FILES
#undef wxHAS_HUGE_STDIO_FILES
#else // Unix or Windows using unknown compiler, assume POSIX supported #else // Unix or Windows using unknown compiler, assume POSIX supported
typedef off_t wxFileOffset; typedef off_t wxFileOffset;
#ifdef _LARGE_FILES #ifdef _LARGE_FILES
@@ -405,6 +421,10 @@ enum wxFileKind
#if SIZEOF_LONG == 8 || defined HAVE_FSEEKO #if SIZEOF_LONG == 8 || defined HAVE_FSEEKO
#define wxHAS_LARGE_FFILES #define wxHAS_LARGE_FFILES
#endif #endif
#ifdef HAVE_FSEEKO
#define wxFseek fseeko
#define wxFtell ftello
#endif
#else #else
#define wxFileOffsetFmtSpec wxT("") #define wxFileOffsetFmtSpec wxT("")
#endif #endif
@@ -443,6 +463,15 @@ enum wxFileKind
#define wxHAS_NATIVE_LSTAT #define wxHAS_NATIVE_LSTAT
#endif // platforms #endif // platforms
// define wxFseek/wxFtell to large file versions if available (done above) or
// to fseek/ftell if not, to save ifdefs in using code
#ifndef wxFseek
#define wxFseek fseek
#endif
#ifndef wxFtell
#define wxFtell ftell
#endif
#ifdef O_BINARY #ifdef O_BINARY
#define wxO_BINARY O_BINARY #define wxO_BINARY O_BINARY
#else #else

View File

@@ -578,6 +578,8 @@
#else #else
# undef wxCHECK_W32API_VERSION # undef wxCHECK_W32API_VERSION
# define wxCHECK_W32API_VERSION(maj, min) (0) # define wxCHECK_W32API_VERSION(maj, min) (0)
# undef wxCHECK_MINGW32_VERSION
# define wxCHECK_MINGW32_VERSION(maj, min) (0)
#endif #endif
#if defined (__WXMSW__) #if defined (__WXMSW__)

View File

@@ -41,18 +41,6 @@
// implementation // implementation
// ============================================================================ // ============================================================================
// ----------------------------------------------------------------------------
// seek and tell with large file support if available
// ----------------------------------------------------------------------------
#ifdef HAVE_FSEEKO
# define wxFseek fseeko
# define wxFtell ftello
#else
# define wxFseek fseek
# define wxFtell ftell
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// opening the file // opening the file
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -206,7 +194,7 @@ bool wxFFile::Seek(wxFileOffset ofs, wxSeekMode mode)
break; break;
} }
#ifndef HAVE_FSEEKO #ifndef wxHAS_LARGE_FFILES
if ((long)ofs != ofs) if ((long)ofs != ofs)
{ {
wxLogError(_("Seek error on file '%s' (large files not supported by stdio)"), m_name.c_str()); wxLogError(_("Seek error on file '%s' (large files not supported by stdio)"), m_name.c_str());

View File

@@ -256,8 +256,8 @@ wxOutputStream *LargeFileTest_wxFFile::MakeOutStream(const wxString& name) const
bool LargeFileTest_wxFFile::HasLFS() const bool LargeFileTest_wxFFile::HasLFS() const
{ {
#ifdef HAVE_FSEEKO #ifdef wxHAS_LARGE_FFILES
return (wxFileOffset)0xffffffff > 0; return true;
#else #else
return false; return false;
#endif #endif