diff --git a/include/wx/ffile.h b/include/wx/ffile.h index e9eaf36db7..8f8ffde014 100644 --- a/include/wx/ffile.h +++ b/include/wx/ffile.h @@ -86,7 +86,8 @@ public: // get current file length size_t Length() const; - // simple accessors + // simple accessors: note that Eof() and Error() may only be called if + // IsOpened()! // is file opened? bool IsOpened() const { return m_fp != NULL; } // is end of file reached? diff --git a/src/common/ffile.cpp b/src/common/ffile.cpp index 95105fbfed..503e5bfa0d 100644 --- a/src/common/ffile.cpp +++ b/src/common/ffile.cpp @@ -206,6 +206,9 @@ bool wxFFile::Seek(long ofs, wxSeekMode mode) size_t wxFFile::Tell() const { + wxCHECK_MSG( IsOpened(), (size_t)-1, + _T("wxFFile::Tell(): file is closed!") ); + long rc = ftell(m_fp); if ( rc == -1 ) { @@ -218,6 +221,9 @@ size_t wxFFile::Tell() const size_t wxFFile::Length() const { + wxCHECK_MSG( IsOpened(), (size_t)-1, + _T("wxFFile::Length(): file is closed!") ); + wxFFile& self = *(wxFFile *)this; // const_cast size_t posOld = Tell();