From 224d978ffb483f93864f8bf9a5cd61b1425a7fd5 Mon Sep 17 00:00:00 2001 From: Michael Wetherell Date: Tue, 22 Dec 2009 21:22:59 +0000 Subject: [PATCH] Add support for large stdio files for VC 8+. What versions of the other Windows compilers? git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62974 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/filefn.h | 33 +++++++++++++++++++++++++++++---- src/common/ffile.cpp | 14 +------------- tests/streams/largefile.cpp | 4 ++-- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/include/wx/filefn.h b/include/wx/filefn.h index 364d83daa5..c5bdf72ef4 100644 --- a/include/wx/filefn.h +++ b/include/wx/filefn.h @@ -172,7 +172,9 @@ enum wxFileKind defined(__BORLANDC__) \ ) + // temporary defines just used immediately below #undef wxHAS_HUGE_FILES + #undef wxHAS_HUGE_STDIO_FILES // detect compilers which have support for huge files #if defined(__VISUALC__) @@ -183,6 +185,13 @@ enum wxFileKind #define wxHAS_HUGE_FILES 1 #endif + // detect compilers which have support for huge stdio files + #if wxCHECK_VISUALC_VERSION(8) + #define wxHAS_HUGE_STDIO_FILES + #define wxFseek _fseeki64 + #define wxFtell _ftelli64 + #endif + // 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) // currently @@ -397,16 +406,19 @@ enum wxFileKind #endif // wxHAS_UNDERSCORES_IN_POSIX_IDENTS #ifdef wxHAS_HUGE_FILES - // wxFile is present and supports large files. Currently wxFFile - // doesn't have large file support with any Windows compiler (even - // Win64 ones). + // wxFile is present and supports large files. #if wxUSE_FILE #define wxHAS_LARGE_FILES #endif + // wxFFile is present and supports large files + #if wxUSE_FFILE && defined wxHAS_HUGE_STDIO_FILES + #define wxHAS_LARGE_FFILES + #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_STDIO_FILES #elif defined (__WXPALMOS__) typedef off_t wxFileOffset; #ifdef _LARGE_FILES @@ -458,6 +470,10 @@ enum wxFileKind #if wxUSE_FFILE && (SIZEOF_LONG == 8 || defined HAVE_FSEEKO) #define wxHAS_LARGE_FFILES #endif + #ifdef HAVE_FSEEKO + #define wxFseek fseeko + #define wxFtell ftello + #endif #else #define wxFileOffsetFmtSpec wxT("") #endif @@ -491,6 +507,15 @@ enum wxFileKind #define wxCRT_Lstat wxCRT_Stat #endif +// 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 + inline int wxAccess(const wxString& path, mode_t mode) { return wxCRT_Access(path.fn_str(), mode); } inline int wxOpen(const wxString& path, int flags, mode_t mode) diff --git a/src/common/ffile.cpp b/src/common/ffile.cpp index 0ca910ed08..7d669169a6 100644 --- a/src/common/ffile.cpp +++ b/src/common/ffile.cpp @@ -42,18 +42,6 @@ // 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 // ---------------------------------------------------------------------------- @@ -215,7 +203,7 @@ bool wxFFile::Seek(wxFileOffset ofs, wxSeekMode mode) break; } -#ifndef HAVE_FSEEKO +#ifndef wxHAS_LARGE_FFILES if ((long)ofs != ofs) { wxLogError(_("Seek error on file '%s' (large files not supported by stdio)"), m_name.c_str()); diff --git a/tests/streams/largefile.cpp b/tests/streams/largefile.cpp index 36ddbb04d9..8f35746d7d 100644 --- a/tests/streams/largefile.cpp +++ b/tests/streams/largefile.cpp @@ -268,8 +268,8 @@ wxOutputStream *LargeFileTest_wxFFile::MakeOutStream(const wxString& name) const bool LargeFileTest_wxFFile::HasLFS() const { -#ifdef HAVE_FSEEKO - return (wxFileOffset)0xffffffff > 0; +#ifdef wxHAS_LARGE_FFILES + return true; #else return false; #endif -- 2.45.2